function tfa_form_alter in Two-factor Authentication (TFA) 7.2
Implements hook_form_alter().
File
- ./
tfa.module, line 231 - Two-factor authentication for Drupal.
Code
function tfa_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_login':
case 'user_login_block':
if (variable_get('tfa_enabled', 0)) {
// Replace Drupal's login submit handler with TFA to check if
// authentication should be interrupted and user redirected to TFA form.
// Replacing user_login_submit() in its position allows other form_alter
// handlers to run after. However, the user must be redirected to the
// TFA form so the last handler in the order must be
// tfa_login_form_redirect(). Other modules may alter the tfa_redirect
// options element as needed to set the destination after TFA.
$key = array_search('user_login_submit', $form['#submit']);
$form['#submit'][$key] = 'tfa_login_submit';
$form['#submit'][] = 'tfa_login_form_redirect';
}
break;
}
}