You are here

protected function TfaBasePlugin::validate in Two-factor Authentication (TFA) 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.

1 method overrides TfaBasePlugin::validate()
TfaRecoveryCode::validate in src/Plugin/TfaValidation/TfaRecoveryCode.php
Validate code.

File

src/Plugin/TfaBasePlugin.php, line 163

Class

TfaBasePlugin
Base plugin class.

Namespace

Drupal\tfa\Plugin

Code

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