1 user.module user_login_name_validate($form, &$form_state)

First phase validation handler for the login form.

Check for invalid email addresses and blocked accounts.

File

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

Code

function user_login_name_validate($form, &$form_state) {
  if (isset($form_state['values']['name'])) {
    $name = $form_state['values']['name'];
    $credentials = config_get('system.core', 'user_login_method');
    if ($credentials !== USER_LOGIN_USERNAME_ONLY) {
      if ($account = db_query("SELECT * FROM {users} WHERE mail = :mail", array(':mail' => $name))->fetchObject()) {
        $name = $account->name;
      }
      // If can't find account, check if valid email address.
      elseif ($credentials === USER_LOGIN_EMAIL_ONLY && !valid_email_address($name)) {
        form_set_error('name', t('The e-mail address %email is not valid.', array('%email' => $form_state['values']['name'])));
      }
    }
    // If can find account, check if user is blocked.
    if ($name && user_is_blocked($name)) {
      form_set_error('name', t('The account for %name has not been activated or is blocked.', array('%name' => $form_state['values']['name'])));
    }
  }
}