protected function TfaBasePlugin::alreadyAcceptedCode in Two-factor Authentication (TFA) 8
Whether code has already been used.
Parameters
string $code: The code to be checked.
Return value
bool TRUE if already used otherwise FALSE
File
- src/
Plugin/ TfaBasePlugin.php, line 232
Class
- TfaBasePlugin
- Base plugin class.
Namespace
Drupal\tfa\PluginCode
protected function alreadyAcceptedCode($code) {
$hash = Crypt::hashBase64(Settings::getHashSalt() . $code);
// Check if the code has already been used or not.
$key = 'tfa_accepted_code_' . $hash;
$result = $this
->getUserData('tfa', $key, $this->uid, $this->userData);
if (!empty($result)) {
$this->alreadyAccepted = TRUE;
return TRUE;
}
return FALSE;
}