You are here

function user_login_validate in Drupal 4

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

File

modules/user.module, line 926
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' => theme('placeholder', $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' => theme('placeholder', $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.') . ' ' . l(t('Have you forgotten your password?'), 'user/password'));
            watchdog('user', t('Login attempt failed for %user.', array(
              '%user' => theme('placeholder', $form_values['name']),
            )));
          }
        }
      }
    }
  }
}