Get the user's two-factor authentication secret
public getTwoFactorSecret ( integer $userID ) : string | ||
$userID | integer | |
return | string |
/** * 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))); }