function tfa_tfa_process in Two-factor Authentication (TFA) 6
Same name and namespace in other branches
- 7 tfa.module \tfa_tfa_process()
Send the code and redirect to entry form.
2 calls to tfa_tfa_process()
- tfa_code_form_validate in ./
tfa.pages.inc - Validate handler for TFA login form.
- tfa_user in ./
tfa.module - Implements hook_user().
File
- ./
tfa.module, line 163 - 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');
drupal_access_denied();
exit;
}
if (tfa_send_code($account)) {
// Clear any previous validation flood entries.
db_query("DELETE FROM {flood} WHERE event = '%s' AND hostname = '%s'", 'tfa_validate', ip_address());
// 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 = NULL;
if (arg(0) == 'user' && arg(1) == 'reset') {
$query = array(
'destination' => 'user/' . $account->uid . '/edit',
);
}
if (!empty($_REQUEST['destination'])) {
$query = array(
'destination' => $_REQUEST['destination'],
);
}
unset($_REQUEST['destination']);
drupal_goto('system/tfa/' . $account->uid . '/' . $login_hash, $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');
}