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 1847 - Enables the user registration and login system.
Code
function user_login_name_validate($form, &$form_state) {
// Ensure POST values are strings. Arrays may come from malformed HTML or
// malicious attacks.
if (is_array($form_state['values']['name'])) {
$form_state['values']['name'] = reset($form_state['values']['name']);
}
if (is_array($form_state['values']['pass'])) {
$form_state['values']['pass'] = reset($form_state['values']['pass']);
}
$name = trim($form_state['values']['name']);
if (strlen($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 email address %email is not valid.', array('%email' => $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' => $name)));
}
}
}