Improve 2FA
This commit is contained in:
@@ -40,7 +40,7 @@ class TotpAuth extends Base implements PostAuthenticationProviderInterface
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'Time-based One-time Password Algorithm';
|
||||
return t('Time-based One-time Password Algorithm');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +55,16 @@ class TotpAuth extends Base implements PostAuthenticationProviderInterface
|
||||
return $otp->checkTotp(Base32::decode($this->secret), $this->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before to prompt the user
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function beforeCode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set validation code
|
||||
*
|
||||
@@ -66,6 +76,18 @@ class TotpAuth extends Base implements PostAuthenticationProviderInterface
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate secret
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function generateSecret()
|
||||
{
|
||||
$this->secret = GoogleAuthenticator::generateRandom();
|
||||
return $this->secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set secret token
|
||||
*
|
||||
@@ -85,10 +107,6 @@ class TotpAuth extends Base implements PostAuthenticationProviderInterface
|
||||
*/
|
||||
public function getSecret()
|
||||
{
|
||||
if (empty($this->secret)) {
|
||||
$this->secret = GoogleAuthenticator::generateRandom();
|
||||
}
|
||||
|
||||
return $this->secret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user