You are here

protected function TfaTotp::alreadyAcceptedCode in TFA Basic plugins 7

Whether code has recently been accepted.

Parameters

string $code:

Return value

bool

1 call to TfaTotp::alreadyAcceptedCode()
TfaTotp::validate in includes/tfa_totp.inc
@copydoc TfaBasePlugin::validate()

File

includes/tfa_totp.inc, line 126
classes for tfa_totp

Class

TfaTotp
Class TfaTotp

Code

protected function alreadyAcceptedCode($code) {
  $hash = hash('sha1', drupal_get_hash_salt() . $code);
  $result = db_query("SELECT code_hash FROM {tfa_accepted_code} WHERE uid = :uid AND code_hash = :code", array(
    ':uid' => $this->context['uid'],
    ':code' => $hash,
  ))
    ->fetchAssoc();
  if (!empty($result)) {
    $this->alreadyAccepted = TRUE;
    return TRUE;
  }
  return FALSE;
}