resetTwoFactorSecret() public method

Get the user's two-factor authentication secret
public resetTwoFactorSecret ( integer $userID ) : boolean
$userID integer
return boolean
Ejemplo n.º 1
0
 /**
  * Make sure the secret exists, then get the GoogleAuth object
  *
  * @param int $userID
  * @return GoogleAuth
  * @throws \Airship\Alerts\Security\UserNotLoggedIn
  */
 protected function twoFactorPreamble(int $userID = 0) : GoogleAuth
 {
     if (!$userID) {
         $userID = $this->getActiveUserId();
     }
     $secret = $this->acct->getTwoFactorSecret($userID);
     if (empty($secret)) {
         if (!$this->acct->resetTwoFactorSecret($userID)) {
             \Airship\json_response(['test2']);
             \Airship\redirect($this->airship_cabin_prefix);
         }
         $secret = $this->acct->getTwoFactorSecret($userID);
     }
     return new GoogleAuth($secret, new TOTP(0, (int) ($this->config('two-factor.period') ?? 30), (int) ($this->config('two-factor.length') ?? 6)));
 }