Index: modules/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user.module,v retrieving revision 1.523 diff -u -F^f -r1.523 user.module --- modules/user.module 22 Oct 2005 15:14:46 -0000 1.523 +++ modules/user.module 27 Oct 2005 20:29:33 -0000 @@ -960,18 +960,26 @@ function user_logout() { drupal_goto(); } - +/** + * Used by the "Request New Password" Form + */ function user_pass() { global $base_url; $edit = isset($_POST['edit']) ? $_POST['edit'] : ''; - - if ($edit['name'] && !($account = user_load(array('name' => $edit['name'], 'status' => 1)))) { + // if given username, look for it in db + if ($edit['name'] && ( !($account = user_load(array('name' => $edit['name'], 'status' => 1))) ||!isset($account->uid))) { form_set_error('name', t('Sorry. The username %name is not recognized.', array('%name' => theme('placeholder', $edit['name'])))); } - else if ($edit['mail'] && !($account = user_load(array('mail' => $edit['mail'], 'status' => 1)))) { + // if given email, look for it in db + elseif ($edit['mail'] && ( !($account = user_load(array('mail' => $edit['mail'], 'status' => 1))) ||!isset($account->uid))) { form_set_error('mail', t('Sorry. The e-mail address %email is not recognized.', array('%email' => theme('placeholder', $edit['mail'])))); } - if ($account) { + // not given username or email + elseif ($edit) { + drupal_set_message(t('You must provide either a username or e-mail address.'), 'error'); + } + // if have required user attributes for mail message + if (isset($account->mail) && isset($account->name)) { $from = variable_get('site_mail', ini_get('sendmail_from')); // Mail one time login URL and instructions. @@ -991,16 +999,13 @@ function user_pass() { } drupal_goto('user'); } - else { - if ($edit) { - drupal_set_message(t('You must provide either a username or e-mail address.'), 'error'); - } - // Display form: + + // Display form: $form['name'] = array('#type' => 'textfield', '#title' => t('Username'), '#default_value' => $edit['name'], '#size' => 30, '#maxlength' => 64); $form['mail'] = array('#type' => 'textfield', '#title' => t('E-mail address'), '#default_value' => $edit['mail'], '#size' => 30, '#maxlength' => 64); $form['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password')); return drupal_get_form('user_logout', $form); - } + } function theme_user_logout($form) {