You are here

function login_security_form_alter in Login Security 6

Same name and namespace in other branches
  1. 8 login_security.module \login_security_form_alter()
  2. 5 login_security.module \login_security_form_alter()
  3. 7 login_security.module \login_security_form_alter()
  4. 2.x login_security.module \login_security_form_alter()

Implementation of hook_form_alter().

File

./login_security.module, line 83
Login Security

Code

function login_security_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_login':
    case 'user_login_block':

      // 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 = array(
        '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';
      break;
  }
}