You are here

function tfa_entry_access in Two-factor Authentication (TFA) 6

Same name and namespace in other branches
  1. 7.2 tfa.module \tfa_entry_access()
  2. 7 tfa.module \tfa_entry_access()

Validate access to TFA code entry form.

1 string reference to 'tfa_entry_access'
tfa_menu in ./tfa.module
Implements hook_menu().

File

./tfa.module, line 48
Two-factor authentication for Drupal.

Code

function tfa_entry_access($uid, $check_hash) {

  // User must be anonymous for the code entry page.
  if (!user_is_anonymous()) {
    return FALSE;
  }

  // Generate a hash for this account.
  $account = user_load(array(
    'uid' => $uid,
  ));
  $hash = tfa_login_hash($account);
  $code = tfa_get_code($uid);

  // Hash must be valid and the code must have been created within the day.
  return $hash == $check_hash && !empty($code) && $code['created'] > time() - 86400;
}