You are here

function noreqnewpass_user_login_final_validate in No Request New Password 7

Same name and namespace in other branches
  1. 8 noreqnewpass.module \noreqnewpass_user_login_final_validate()
  2. 6 noreqnewpass.module \noreqnewpass_user_login_final_validate()
  3. 7.2 noreqnewpass.module \noreqnewpass_user_login_final_validate()

Just for remove request password url at error messages.

1 string reference to 'noreqnewpass_user_login_final_validate'
noreqnewpass_form_alter in ./noreqnewpass.module
Implementation of hook_form_alter().

File

./noreqnewpass.module, line 97

Code

function noreqnewpass_user_login_final_validate($form_id, &$form_state) {
  if (empty($form_state['uid'])) {

    // Always register an IP-based failed login event.
    flood_register_event('failed_login_attempt_ip', variable_get('user_failed_login_ip_window', 3600));

    // Register a per-user failed login event.
    if (isset($form_state['flood_control_user_identifier'])) {
      flood_register_event('failed_login_attempt_user', variable_get('user_failed_login_user_window', 21600), $form_state['flood_control_user_identifier']);
    }
    if (isset($form_state['flood_control_triggered'])) {
      if ($form_state['flood_control_triggered'] == 'user') {
        form_set_error('name', format_plural(variable_get('user_failed_login_user_limit', 5), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later.'));
      }
      else {

        // We did not find a uid, so the limit is IP-based.
        form_set_error('name', t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later.'));
      }
    }
    else {
      form_set_error('name', t('Sorry, unrecognized username or password.'));
      watchdog('user', 'Login attempt failed for %user.', array(
        '%user' => $form_state['values']['name'],
      ));
    }
  }
  elseif (isset($form_state['flood_control_user_identifier'])) {

    // Clear past failures for this user so as not to block a user who might
    // log in and out more than once in an hour.
    flood_clear_event('failed_login_attempt_user', $form_state['flood_control_user_identifier']);
  }
}