You are here

function noreqnewpass_user_login_validate in No Request New Password 5

File

./noreqnewpass.module, line 79

Code

function noreqnewpass_user_login_validate($form_id, $form_values) {
  if ($form_values['name']) {
    if (user_is_blocked($form_values['name'])) {

      // blocked in user administration
      form_set_error('name', t('The username %name has not been activated or is blocked.', array(
        '%name' => $form_values['name'],
      )));
    }
    else {
      if (drupal_is_denied('user', $form_values['name'])) {

        // denied by access controls
        form_set_error('name', t('The name %name is a reserved username.', array(
          '%name' => $form_values['name'],
        )));
      }
      else {
        if ($form_values['pass']) {
          $user = user_authenticate($form_values['name'], trim($form_values['pass']));
          if (!$user->uid) {
            form_set_error('name', t('Sorry, unrecognized username or password.'));
            watchdog('user', t('Login attempt failed for %user.', array(
              '%user' => $form_values['name'],
            )));
          }
        }
      }
    }
  }
}