function login_security_form_alter in Login Security 2.x
Same name and namespace in other branches
- 8 login_security.module \login_security_form_alter()
- 5 login_security.module \login_security_form_alter()
- 6 login_security.module \login_security_form_alter()
- 7 login_security.module \login_security_form_alter()
Implements hook_form_alter().
File
- ./
login_security.module, line 46 - Login Security module hooks.
Code
function login_security_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'user_login_form') {
// Put login_security first or the capture of the previous login
// timestamp won't work and core's validation will update to the current
// login instance before login_security can read the old timestamp.
$validate = [
'login_security_soft_block_validate',
'login_security_set_login_timestamp',
];
if (isset($form['#validate']) && is_array($form['#validate'])) {
$form['#validate'] = array_merge($validate, $form['#validate']);
}
else {
$form['#validate'] = $validate;
}
$form['#validate'][] = 'login_security_validate';
$form['#submit'][] = 'login_security_submit';
}
}