You are here

protected function TfaBasePlugin::validate in Two-factor Authentication (TFA) 7.2

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.

4 calls to TfaBasePlugin::validate()
TfaTestFallback::validateForm in tests/includes/tfa_test.fallback.inc
Validate form.
TfaTestSend::validateForm in tests/includes/tfa_test.send.inc
Validate form.
TfaTestSendSetup::validateSetupForm in tests/includes/tfa_test.send.inc
Validate setup form.
TfaTestTotp::validateForm in tests/includes/tfa_test.totp.inc
Validate form.

File

./tfa.inc, line 541
TFA module classes.

Class

TfaBasePlugin
Base plugin class.

Code

protected function validate($code) {
  if ($this
    ->timingSafeEquals((string) $code, (string) $this->code)) {
    $this->isValid = TRUE;
    return TRUE;
  }
  else {
    return FALSE;
  }
}