Problem adding third party external accounts in XF 1.3 Beta

HowIChrgeLazer

Well-known member
So when I'm attempting to extend XenForo_ControllerPublic_Account [actionExternalAccounts() and actionExternalAccountsDisassociate()] to take advantage of the new authentication system, my current method is overriding all other account integration options.

I know I'm missing something thing here and I believe it has to do with utilizing something like parent::actionExternalAccounts(); so it'll include what XenForo has and other addons that may also extend XenForo_ControllerPublic_Account. Either I completely break the page or override all other external account options and my addon ends up being the only external account association available.

I tried digging around for an example to follow, but I can't seem to find a proper one. How would I go about returning that parent information plus my addon template/code so all available third party external accounts show?

Here's part of the code so far:

PHP:
class Steam_ControllerPublic_Account extends XFCP_Steam_ControllerPublic_Account {

    public function actionExternalAccounts()
    {
        $sHelper = new Steam_Helper_Steam();
        $visitor = XenForo_Visitor::getInstance();

        $auth = $this->_getUserModel()->getUserAuthenticationObjectByUserId($visitor['user_id']);
        if (!$auth)
        {
            return $this->responseNoPermission();
        }
        $externalAuthModel = $this->getModelFromCache('XenForo_Model_UserExternal');
        $external = $externalAuthModel->getExternalAuthAssociationsForUser($visitor['user_id']);

        $stUser = false;
        if (!empty($external['steam']))
        {
            $extra = @unserialize($external['steam']);
            if (!empty($extra['provider_key']))
            {
                $stUser = $sHelper->getUserInfo($extra['provider_key']);
            }
        }

        $viewParams = array(
            'external' => $external,
            'stUser' => $stUser,
            'hasPassword' => $auth->hasPassword()
        );
/* This obviously isn't correct */
        return parent::_getWrapper('account', 'externalAccounts', $this->responseView('XenForo_ViewPublic_Account_ExternalAccounts_Steam', 'account_external_accounts_steam', $viewParams));
/*
        return $this->_getWrapper(
            'account', 'externalAccounts',
            $this->responseView('XenForo_ViewPublic_Account_ExternalAccounts_Steam', 'account_external_accounts_steam', $viewParams)
        );*/
    }

Any help would be appreciated. I wouldn't be surprised if it hit me tomorrow, but I've been stuck for a little bit this evening/morning so I figure I'd ask.
 
Last edited:
Anybody have input?

I moved my template edits to XenForo's Template Modification system so my External Account shows along with XenForo's.

However, I'm still having issues extending Xenforo_ControllerPublic_Account

PHP:
class Steam_ControllerPublic_Account extends XFCP_Steam_ControllerPublic_Account {
   
    public function actionExternalAccounts()
    {
        $response = parent::actionExternalAccounts();

        $stUser = false;
        if (!empty($response->external['steam']))
        {
            $stExtra = @unserialize($response->external['steam']['extra_data']);
            if (!empty($stExtra['provider_key']))
            {
                $sHelper = new Steam_Helper_Steam();
                $stUser = $sHelper->getUserInfo($stExtra['provider_key']);
            }
        }

        /*
        DEBUG
            $stUser = array(
            'username' => 'Working',
            'avatar' => 'http://media.steampowered.com/steamcommunity/public/images/avatars/b3/b3cea64d824a49a83fa7e3e5c30eba6ed501d94d.jpg'
        );
        */
       
        $stParams = $response->params;
       
        $stParams['stUser'] = $stUser;
        $response->params = $stParams;

        return $response;
    }

    public function actionExternalAccountsDisassociate()
    {
        $response = parent::actionExternalAccountsDisassociate();

        if ($input['disassociate'] && $input['account'])
        {
            $sHelper = new Steam_Helper_Steam();
            $sHelper->deleteSteamData($visitor['user_id']);
        }

        return $response;
    }

I'm dumping $stUser on the account page and I'm only getting NULL. At the very least I should see bool(false), but the only way I can get that to show is if I do the return like this:

PHP:
        $viewParams = $response->params;
       
        $viewParams['stUser'] = $stUser;

        return parent::_getWrapper('account', 'externalAccounts', $this->responseView('XenForo_ViewPublic_Account_ExternalAccounts', 'account_external_accounts', $viewParams));

I just don't know if that's the proper the way of doing it.
 
I think it's to do with the account page wrapper.

You want to add your params to:

PHP:
$response->subView->params

(That's from memory, I recommend dumping $response... you should see a second instance of XenForo_ControllerResponse_View in there with a separate set of params).
 
Top Bottom