protected function GALoginHotpSetup::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 GALoginHotpValidation::validate
1 call to GALoginHotpSetup::validate()
- GALoginHotpSetup::validateSetupForm in src/
Plugin/ TfaSetup/ GALoginHotpSetup.php - Validate the setup data.
File
- src/
Plugin/ TfaSetup/ GALoginHotpSetup.php, line 125
Class
- GALoginHotpSetup
- HOTP setup class to setup HOTP validation.
Namespace
Drupal\ga_login\Plugin\TfaSetupCode
protected function validate($code) {
// The counter is set as 1 because that is the initial value.
// This ensures that things work even if we reset the application.
$code = preg_replace('/\\s+/', '', $code);
$counter = $this->auth->otp
->checkHotpResync(Encoding::base32DecodeUpper($this->seed), 1, $code, $this->counterWindow);
$this
->setUserData('tfa', [
'tfa_hotp_counter' => ++$counter,
], $this->uid, $this->userData);
return (bool) $counter;
}