verify() публичный Метод

If no timestamp is provided, the OTP is verified at the actual timestamp {@inheritdoc}
public verify ( $otp, $timestamp = null, $window = null )
 /**
  * @dataProvider testVerifyData
  */
 public function testVerify($secret, $input, $output, $expectedResult)
 {
     $totp = new TOTP($secret);
     $this->assertEquals($expectedResult, $totp->verify($output, $input));
 }
 /**
  * Verify one time code using the otp instance
  * @param $one_time_code
  * @param TOTP|null $totp
  * @return bool
  */
 public function verifyCode($one_time_code, TOTP $totp = null)
 {
     if ($totp !== null) {
         return $totp->verify($one_time_code);
     } else {
         return $this->totp->verify($one_time_code);
     }
 }
Пример #3
0
 public function onValidateOneTimePassword($value)
 {
     switch ($this->oneTimePasswordType) {
         case TwoFactorAuthentication::OTP_HOTP:
             $oneTimePassword = new HOTP('', $this->getOneTimePasswordCode());
             break;
         case TwoFactorAuthentication::OTP_TOTP:
             $oneTimePassword = new TOTP('', $this->getOneTimePasswordCode());
             break;
         default:
             throw new RuntimeException('No valid OTP type set: ' . $this->oneTimePasswordType);
     }
     return $oneTimePassword->verify($value);
 }