You are here

function user_login_validate in Drupal 5

Same name and namespace in other branches
  1. 4 modules/user.module \user_login_validate()

File

modules/user/user.module, line 930
Enables the user registration and login system.

Code

function 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. <a href="@password">Have you forgotten your password?</a>', array(
              '@password' => url('user/password'),
            )));
            watchdog('user', t('Login attempt failed for %user.', array(
              '%user' => $form_values['name'],
            )));
          }
        }
      }
    }
  }
}