diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 9fdcb79..82fd1fc 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -30,6 +30,8 @@ function user_autocomplete($string = '') { function user_pass($form, &$form_state) { global $user; + // When a user requests a password reset we check for username and email + // conflicts using a multistep form. if (empty($form_state['step'])) { $form_state['step'] = 1; } @@ -54,20 +56,22 @@ function user_pass($form, &$form_state) { } } else { + // Where there is a conflict between the username and email address for two + // users we supply both accounts as an option for the password reset. $accounts = $form_state['storage']['accounts']; $options = array(); foreach ($accounts as $account) { $label = t('Account name: @name', array('@name' => $account->name)); if ($account->mail == $form_state['storage']['name']) { - $label .= '/ ' . t('Email Address: @email', array('@email' => $account->mail)); + $label .= '/ ' . t('Email address: @email', array('@email' => $account->mail)); } $options[$account->uid] = $label; } $form['choose_account'] = array( '#type' => 'radios', - '#title' => t('Choose Account'), + '#title' => t('Choose account'), '#required' => TRUE, - '#prefix' => "
" . t("The email address @email was matched to to multiple accounts. Please select which account's password should be reset.", array('@email' => $form_state['storage']['name'])) . "
", + '#prefix' => "" . t("There is a username conflict with the email address @email. Please select which account password to reset.", array('@email' => $form_state['storage']['name'])) . "
", '#options' => $options, '#default_value' => reset($accounts)->uid, ); @@ -144,7 +148,7 @@ function user_pass_submit($form, &$form_state) { } } if (isset($account)) { - // Mail one time login URL and instructions using current language. + // Mail one-time login URL and instructions using current language. $mail = _user_mail_notify('password_reset', $account, $language_interface); if (!empty($mail)) { watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail)); diff --git a/core/modules/user/user.test b/core/modules/user/user.test index ce2c580..c653bc2 100644 --- a/core/modules/user/user.test +++ b/core/modules/user/user.test @@ -439,7 +439,7 @@ class UserLoginTestCase extends DrupalWebTestCase { } /** - * Test Resetting a user's password. + * Tests resetting a user's password. */ class UserPasswordResetTestCase extends DrupalWebTestCase { public static function getInfo() { @@ -451,7 +451,7 @@ class UserPasswordResetTestCase extends DrupalWebTestCase { } /** - * Attempt to reset a password when an email address matches two accounts. + * Attempts to reset a password when an email address matches two accounts. */ function testUserPasswordResetDuplicateUsers() { // Don't require email validation for new accounts. @@ -470,8 +470,8 @@ class UserPasswordResetTestCase extends DrupalWebTestCase { $edit['pass[pass1]'] = $new_pass = $this->randomName(); $edit['pass[pass2]'] = $new_pass; $this->drupalPost('user/register', $edit, t('Create new account')); - // To maintain upgradability, registration with an account name that is - // used as the email adderess as another account should be allowed. + // For backward compatibility, registration with a username that conflicts + // with an email address of another account should be allowed. $this->assertText(t('Registration successful. You are now logged in.'), t('Users are logged in after registering.')); // The above logs in the user. Log out to test password reset. $this->drupalLogout(); @@ -490,7 +490,7 @@ class UserPasswordResetTestCase extends DrupalWebTestCase { // We should be sure to not expose another user's email to the user. $this->assertNoText($user_with_name->mail, "Duplicated user's email is not exposed to the other user."); - // Select the account with the username matching the entered email; + // Select the account with the username matching the entered email. $edit = array(); $edit['choose_account'] = $user_with_email->uid; $this->drupalPost(NULL, $edit, t('E-mail new password')); @@ -507,13 +507,13 @@ class UserPasswordResetTestCase extends DrupalWebTestCase { $this->drupalLogin($user_with_name); $this->drupalGet('user/password'); // There should not be a form element for name. - $this->assertNoField('name', 'Duplicate user is not asked for a name when resetting password while logged in'); + $this->assertNoField('name', 'Duplicate user is not asked for a name when resetting password while logged in.'); $this->drupalPost(NULL, array(), t('E-mail new password')); - // Make sure the user was sent an email. + // Make sure the user with the matching username was sent an email. $this->assertText(t('Further instructions have been sent to your e-mail address.'), 'User is notified that password reset was sent when logged in.'); $this->assertEqual(count($this->drupalGetMails(array('key' => 'password_reset', 'to' => $user_with_name->mail))), 1, 'The right user was sent a password reset mail when logged in.'); - // Make sure that the other user was not sent an email. (Remembering that - // one has already been sent to this user earlier) + // Make sure that the user with the matching email address was not sent an + // email. (An email was already sent to this user earlier.) $this->assertEqual(count($this->drupalGetMails(array('key' => 'password_reset', 'to' => $user_with_email->mail))), 1, 'The other user was not sent a password reset mail when logged in.'); } }