Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/factor/PhabricatorTOTPAuthFactor.php
Show All 17 Lines | final class PhabricatorTOTPAuthFactor extends PhabricatorAuthFactor { | ||||
public function getFactorDescription() { | public function getFactorDescription() { | ||||
return pht( | return pht( | ||||
'Attach a mobile authenticator application (like Authy '. | 'Attach a mobile authenticator application (like Authy '. | ||||
'or Google Authenticator) to your account. When you need to '. | 'or Google Authenticator) to your account. When you need to '. | ||||
'authenticate, you will enter a code shown on your phone.'); | 'authenticate, you will enter a code shown on your phone.'); | ||||
} | } | ||||
public function getEnrollDescription( | |||||
PhabricatorAuthFactorProvider $provider, | |||||
PhabricatorUser $user) { | |||||
return pht( | |||||
'To add a TOTP factor to your account, you will first need to install '. | |||||
'a mobile authenticator application on your phone. Two applications '. | |||||
'which work well are **Google Authenticator** and **Authy**, but any '. | |||||
'other TOTP application should also work.'. | |||||
"\n\n". | |||||
'If you haven\'t already, download and install a TOTP application on '. | |||||
'your phone now. Once you\'ve launched the application and are ready '. | |||||
'to add a new TOTP code, continue to the next step.'); | |||||
} | |||||
public function processAddFactorForm( | public function processAddFactorForm( | ||||
PhabricatorAuthFactorProvider $provider, | PhabricatorAuthFactorProvider $provider, | ||||
AphrontFormView $form, | AphrontFormView $form, | ||||
AphrontRequest $request, | AphrontRequest $request, | ||||
PhabricatorUser $user) { | PhabricatorUser $user) { | ||||
$sync_token = $this->loadMFASyncToken( | $sync_token = $this->loadMFASyncToken( | ||||
$request, | $request, | ||||
Show All 21 Lines | if (!$sync_token->getIsNewTemporaryToken()) { | ||||
if (!strlen($code)) { | if (!strlen($code)) { | ||||
$e_code = pht('Required'); | $e_code = pht('Required'); | ||||
} else { | } else { | ||||
$e_code = pht('Invalid'); | $e_code = pht('Invalid'); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$form->appendRemarkupInstructions( | |||||
pht( | |||||
'First, download an authenticator application on your phone. Two '. | |||||
'applications which work well are **Authy** and **Google '. | |||||
'Authenticator**, but any other TOTP application should also work.')); | |||||
$form->appendInstructions( | $form->appendInstructions( | ||||
pht( | pht( | ||||
'Launch the application on your phone, and add a new entry for '. | 'Scan the QR code or manually enter the key shown below into the '. | ||||
'this Phabricator install. When prompted, scan the QR code or '. | 'application.')); | ||||
'manually enter the key shown below into the application.')); | |||||
$prod_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/')); | $prod_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/')); | ||||
$issuer = $prod_uri->getDomain(); | $issuer = $prod_uri->getDomain(); | ||||
$uri = urisprintf( | $uri = urisprintf( | ||||
'otpauth://totp/%s:%s?secret=%s&issuer=%s', | 'otpauth://totp/%s:%s?secret=%s&issuer=%s', | ||||
$issuer, | $issuer, | ||||
$user->getUsername(), | $user->getUsername(), | ||||
▲ Show 20 Lines • Show All 408 Lines • Show Last 20 Lines |