You are here

function tfa_login in Two-factor Authentication (TFA) 7.2

Authenticate the user.

Parameters

object $account: User account object.

1 call to tfa_login()
tfa_form_submit in ./tfa.form.inc
TFA form submission handler.

File

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

Code

function tfa_login($account) {
  global $user;
  $user = $account;

  // Update the user table timestamp noting user has logged in.
  $user->login = REQUEST_TIME;
  db_update('users')
    ->fields(array(
    'login' => $user->login,
  ))
    ->condition('uid', $user->uid)
    ->execute();

  // Regenerate the session ID to prevent against session fixation attacks.
  drupal_session_regenerate();
  watchdog('tfa', 'Session opened for %name.', array(
    '%name' => $user->name,
  ));

  // Clear existing context and set master authenticated context.
  tfa_clear_context($user);
  $_SESSION['tfa'][$user->uid]['login'] = TRUE;

  // Truncate flood for user.
  flood_clear_event('tfa_begin');
  $identifier = variable_get('user_failed_login_identifier_uid_only', FALSE) ? $account->uid : $account->uid . '-' . ip_address();
  flood_clear_event('tfa_user', $identifier);
  $edit = array();
  user_module_invoke('login', $edit, $user);
}