--- user.pages.inc 2010-06-02 13:03:07.000000000 +0100 +++ user.pages2.inc 2010-09-10 15:47:02.000000000 +0100 @@ -43,7 +43,12 @@ function user_pass() { function user_pass_validate($form, &$form_state) { $name = trim($form_state['values']['name']); - + + // Blocked accounts cannot request a new password, + // check provided username and email against access rules. + if (drupal_is_denied('user', $name) || drupal_is_denied('mail', $name)) { + form_set_error('name', t('%name is not allowed to request a new password.', array('%name' => $name))); + } // Try to load by email. $account = user_load(array('mail' => $name, 'status' => 1)); @@ -51,16 +56,17 @@ function user_pass_validate($form, &$for // No success, try to load by name. $account = user_load(array('name' => $name, 'status' => 1)); } - if ($account) { - // Blocked accounts cannot request a new password, - // check provided username and email against access rules. - if (drupal_is_denied('user', $account->name) || drupal_is_denied('mail', $account->mail)) { - form_set_error('name', t('%name is not allowed to request a new password.', array('%name' => $name))); - } + + $name = $form_state['values']['name']; + // Check if the account name exists, and if the account status is '0' + if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE name = '%s';", $name)) && $account->status == 0) { + form_set_error('name', t('The username %name has not been activated or is blocked.', array('%name' => $name))); } + if (isset($account->uid)) { form_set_value(array('#parents' => array('account')), $account, $form_state); } + else { form_set_error('name', t('Sorry, %name is not recognized as a user name or an e-mail address.', array('%name' => $name))); }