You are here

function tfa_entry_access in Two-factor Authentication (TFA) 7

Same name and namespace in other branches
  1. 6 tfa.module \tfa_entry_access()
  2. 7.2 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 34
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($uid);
  $hash = tfa_login_hash($account);
  $code = tfa_get_code($uid);

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