XF 2.0 Using GoogleAuthenticator externally

LPH

Well-known member
I'm trying to build a way to use Google Authenticator (and twitter, facebook, etc) externally to log into XenForo 2.

This is my current attempt.

Code:
$options = \XF::app()->get( 'options' );

$googleClientId = $options->googleClientId;

$visitor = \XF::visitor();

echo '<span class="googleLogin GoogleLogin JsOnly" tabindex="110" data-client-id="'
     . $googleClientId
     . '" data-redirect-url="'
     . \XF::app()->router()->buildLink( 'canonical:register/google?code=__CODE__&amp;csrf=' . $visitor['csrf.token'] )
     . '" data-gapiattached="true"><span>Log in with Google</span></span>';

I'm thinking there should be a way to use the XF:Tfa but am lost in that code. Any guidance would be helpful.

Code:
/** @var \XF\Repository\Tfa $tfaRepo */
$tfaRepo = \XF::repository('XF:Tfa');
$tfaRepo->updateUserTfaData($user, $provider, $newProviderData);
 
Google Authenticator is for 2FA, specifically what's known as TOTP. You don't really need to be involved with 2FA for the most part as it is something we would trigger after a user is logging in. So I don't think this is what you want.

The first set of code you've shown looks pretty explicitly like XF1 code. The configuration won't be in the options any longer and there's no JS SDK integration.
 
Back
Top Bottom