- Patch #135329 by Zen: clean up password reset form.

6.x
Dries Buytaert 2007-04-13 08:42:36 +00:00
parent e6f10554dd
commit ea3c495a55
1 changed files with 11 additions and 12 deletions

View File

@ -1156,32 +1156,31 @@ function user_logout() {
} }
function user_pass() { function user_pass() {
$form['name'] = array(
// Display form: '#type' => 'textfield',
$form['name'] = array('#type' => 'textfield',
'#title' => t('Username or e-mail address'), '#title' => t('Username or e-mail address'),
'#size' => 60, '#size' => 60,
'#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH), '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH),
'#required' => TRUE, '#required' => TRUE,
); );
$form['submit'] = array('#type' => 'submit', $form['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password'));
'#value' => t('E-mail new password'),
'#weight' => 2,
);
return $form; return $form;
} }
function user_pass_validate($form_id, $form_values) { function user_pass_validate($form_id, $form_values) {
$name = $form_values['name']; $name = trim($form_values['name']);
$account = user_load(array('mail' => $name, 'status' => 1)); if (valid_email_address($name)) {
if (!$account) { $account = user_load(array('mail' => $name, 'status' => 1));
}
else {
$account = user_load(array('name' => $name, 'status' => 1)); $account = user_load(array('name' => $name, 'status' => 1));
} }
if ($account->uid) { if (isset($account->uid)) {
form_set_value(array('#parents' => array('account')), $account); form_set_value(array('#parents' => array('account')), $account);
} }
else { 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)));
} }
} }