Commit eef5c498 authored by Dries's avatar Dries

- Patch #82435 by chx: usability: reworked the 'request new password' form.

parent 9c7eecaa
...@@ -905,7 +905,7 @@ function user_login_validate($form_id, $form_values) { ...@@ -905,7 +905,7 @@ function user_login_validate($form_id, $form_values) {
$user = user_authenticate($form_values['name'], trim($form_values['pass'])); $user = user_authenticate($form_values['name'], trim($form_values['pass']));
if (!$user->uid) { if (!$user->uid) {
form_set_error('login', t('Sorry. Unrecognized username or password.') .' '. l(t('Have you forgotten your password?'), 'user/password')); form_set_error('login', t('Sorry, unrecognized username or password.') .' '. l(t('Have you forgotten your password?'), 'user/password'));
watchdog('user', t('Login attempt failed for %user.', array('%user' => $form_values['name']))); watchdog('user', t('Login attempt failed for %user.', array('%user' => $form_values['name'])));
} }
} }
...@@ -1004,14 +1004,10 @@ function user_pass() { ...@@ -1004,14 +1004,10 @@ function user_pass() {
// Display form: // Display form:
$form['name'] = array('#type' => 'textfield', $form['name'] = array('#type' => 'textfield',
'#title' => t('Username'), '#title' => t('Username or e-mail address'),
'#size' => 30, '#size' => 30,
'#maxlength' => 60, '#maxlength' => 60,
); '#required' => TRUE,
$form['mail'] = array('#type' => 'textfield',
'#title' => t('E-mail address'),
'#size' => 30,
'#maxlength' => 64,
); );
$form['submit'] = array('#type' => 'submit', $form['submit'] = array('#type' => 'submit',
'#value' => t('E-mail new password'), '#value' => t('E-mail new password'),
...@@ -1020,19 +1016,17 @@ function user_pass() { ...@@ -1020,19 +1016,17 @@ function user_pass() {
return $form; return $form;
} }
function user_pass_validate() { function user_pass_validate($form_id, $form_values) {
global $form_values;
$name = $form_values['name']; $name = $form_values['name'];
$mail = $form_values['mail']; $account = user_load(array('mail' => $name, 'status' => 1));
if ($name && !($form_values['account'] = user_load(array('name' => $name, 'status' => 1)))) { if (!$account) {
form_set_error('name', t('Sorry. The username %name is not recognized.', array('%name' => $name))); $account = user_load(array('name' => $name, 'status' => 1));
} }
else if ($mail && !($form_values['account'] = user_load(array('mail' => $mail, 'status' => 1)))) { if ($account->uid) {
form_set_error('mail', t('Sorry. The e-mail address %email is not recognized.', array('%email' => $mail))); form_set_value(array('#parents' => array('account')), $account);
} }
else if (!$mail && !$name) { else {
form_set_error('password', t('You must provide either a username or e-mail address.')); form_set_error('name', t('Sorry, %name is not recognized as a user name or an email address.', array('%name' => $name)));
} }
} }
...@@ -1059,12 +1053,6 @@ function user_pass_submit($form_id, $form_values) { ...@@ -1059,12 +1053,6 @@ function user_pass_submit($form_id, $form_values) {
return 'user'; return 'user';
} }
function theme_user_pass($form) {
$output = '<p>'. t('Enter your username <strong><em>or</em></strong> your e-mail address.') .'</p>';
$output .= drupal_render($form);
return $output;
}
/** /**
* Menu callback; process one time login link and redirects to the user page on success. * Menu callback; process one time login link and redirects to the user page on success.
*/ */
......
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