function tfa_tfa_process in Two-factor Authentication (TFA) 7
Same name and namespace in other branches
- 6 tfa.module \tfa_tfa_process()
Send the code and redirect to entry form.
2 calls to tfa_tfa_process()
- tfa_resend_code in ./
tfa.pages.inc - Resend code.
- tfa_user_login in ./
tfa.module - Implements hook_user_login().
File
- ./
tfa.module, line 165 - Two-factor authentication for Drupal.
Code
function tfa_tfa_process($account) {
// Send the code and if succesfull provide the entry form.
if (!flood_is_allowed('tfa_send', variable_get('tfa_hourly_threshold', 5))) {
drupal_set_message(t('You have reached the hourly threshold for login attempts. Please try again later.'), 'error');
return drupal_access_denied();
}
if (tfa_send_code($account)) {
drupal_set_message(t('A message containing the code has been sent.'));
// Clear any previous validation flood entries.
flood_clear_event('tfa_validate');
// Register send event.
flood_register_event('tfa_send');
// Generate hash for code entry form.
$login_hash = tfa_login_hash($account);
// Hold onto destination and unset GET parameter.
$query = drupal_get_query_parameters();
if (arg(0) == 'user' && arg(1) == 'reset') {
$query = array(
'destination' => 'user/' . $account->uid . '/edit',
);
}
unset($_GET['destination']);
drupal_goto('system/tfa/' . $account->uid . '/' . $login_hash, array(
'query' => $query,
));
}
else {
drupal_set_message(t('There was an error while trying to send the login code, please try again later or contact a site administator.'));
}
drupal_goto('user');
}