You are here

protected function GALoginTotpSetup::validate in Google Authenticator login 8

Validate code.

Note, plugins overriding validate() should be sure to set isValid property correctly or else also override submitForm().

Parameters

string $code: Code to be validated.

Return value

bool Whether code is valid.

Overrides GALoginTotpValidation::validate

1 call to GALoginTotpSetup::validate()
GALoginTotpSetup::validateSetupForm in src/Plugin/TfaSetup/GALoginTotpSetup.php
Validate the setup data.

File

src/Plugin/TfaSetup/GALoginTotpSetup.php, line 125

Class

GALoginTotpSetup
TOTP setup class to setup TOTP validation.

Namespace

Drupal\ga_login\Plugin\TfaSetup

Code

protected function validate($code) {
  $code = preg_replace('/\\s+/', '', $code);
  return $this->auth->otp
    ->checkTotp(Encoding::base32DecodeUpper($this->seed), $code, $this->timeSkew);
}