settings->get('verified');
}
/** @inheritdoc */
public function getLabel()
{
return 'Google Authenticator (TOTP)';
}
/** @inheritdoc */
public function renderProfileForm(Form $form)
{
global $conf;
global $USERINFO;
$secret = $this->getSecret();
$name = $USERINFO['name'] . '@' . $conf['title'];
$url = 'otpauth://totp/' . rawurlencode($name) . '?secret=' . $secret;
$svg = QRCode::svg($url);
$form->addHTML(' ' . $this->getLang('directions') . ''.$secret.'
' . $this->getLang('verifynotice') . '
'); $form->addElement(new OtpField('googleauth_verify')); return $form; } /** @inheritdoc */ public function handleProfileForm() { global $INPUT; // create secret when setup is initialized if ($INPUT->bool('init')) { $this->initSecret(); } $otp = $INPUT->str('googleauth_verify'); if (!$otp) return; if ($this->checkCode($otp)) { $this->settings->set('verified', true); } } /** * @inheritDoc */ public function transmitMessage($code) { return $this->getLang('verifymodule'); } }