diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-04-13 08:42:36 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-04-13 08:42:36 +0000 |
commit | ea3c495a55c7f4a7684d4093b68121985c101e64 (patch) | |
tree | 8f062594c976218fbc682d9e7589f11dd93e53c7 | |
parent | e6f10554dd45ca1acffc1481ce6945eeef56b234 (diff) | |
download | brdo-ea3c495a55c7f4a7684d4093b68121985c101e64.tar.gz brdo-ea3c495a55c7f4a7684d4093b68121985c101e64.tar.bz2 |
- Patch #135329 by Zen: clean up password reset form.
-rw-r--r-- | modules/user/user.module | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index ebfab256d..49a6204aa 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1156,32 +1156,31 @@ function user_logout() { } function user_pass() { - - // Display form: - $form['name'] = array('#type' => 'textfield', + $form['name'] = array( + '#type' => 'textfield', '#title' => t('Username or e-mail address'), '#size' => 60, '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH), '#required' => TRUE, ); - $form['submit'] = array('#type' => 'submit', - '#value' => t('E-mail new password'), - '#weight' => 2, - ); + $form['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password')); + return $form; } function user_pass_validate($form_id, $form_values) { - $name = $form_values['name']; - $account = user_load(array('mail' => $name, 'status' => 1)); - if (!$account) { + $name = trim($form_values['name']); + if (valid_email_address($name)) { + $account = user_load(array('mail' => $name, 'status' => 1)); + } + else { $account = user_load(array('name' => $name, 'status' => 1)); } - if ($account->uid) { + if (isset($account->uid)) { form_set_value(array('#parents' => array('account')), $account); } else { - form_set_error('name', t('Sorry, %name is not recognized as a user name or an email address.', array('%name' => $name))); + form_set_error('name', t('Sorry, %name is not recognized as a user name or an e-mail address.', array('%name' => $name))); } } |