Commit c496aea9 authored by moshe weitzman's avatar moshe weitzman

#260228 by moshe weitzman. Simpler and earlier validation. Committed with permission form Chris.

parent 126c141b
......@@ -53,12 +53,12 @@ function email_registration_form_alter(&$form, $form_state, $form_id) {
$form['name']['#title'] = t('E-mail');
$form['name']['#description'] = 'Enter your e-mail address.';
$form['pass']['#description'] = 'Enter the password that accompanies your e-mail.';
$form['#validate'] = array('email_registration_user_login_validate' => array()) + $form['#validate'];
$form['name']['#element_validate'][] = 'email_registration_user_login_validate';
break;
case 'user_login_block':
$form['name']['#title'] = t('E-mail');
$form['#validate'] = array('email_registration_user_login_validate' => array()) + $form['#validate'];
$form['name']['#element_validate'][] = 'email_registration_user_login_validate';
break;
}
}
......@@ -80,7 +80,7 @@ function email_registration_form_alter(&$form, $form_state, $form_id) {
function email_registration_user_login_validate($form, &$form_state) {
if (isset($form_state['values']['name'])) {
if ($name = db_result(db_query("SELECT name FROM {users} WHERE LOWER(mail) = LOWER('%s')", $form_state['values']['name']))) {
form_set_value($form_state['name'], $name, $form_state);
$form_state['values']['name'] = $name;
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment