diff options
author | David Rothstein <drothstein@gmail.com> | 2013-08-05 00:37:49 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-08-05 00:37:49 -0400 |
commit | 1b0d6d22d336d23c0c3bb29cd0468a03ab3fbb4a (patch) | |
tree | e8cdbdf0f283bee96294d7f1d4ba3632f89720ac /modules | |
parent | f746ed8ecc97a45db007002cd2d977cac3aad1cc (diff) | |
download | brdo-1b0d6d22d336d23c0c3bb29cd0468a03ab3fbb4a.tar.gz brdo-1b0d6d22d336d23c0c3bb29cd0468a03ab3fbb4a.tar.bz2 |
Issue #1952196 by greggles, sandhya.m: Usability: if a user has just failed a login, default their username on password reset.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/user/user.module | 2 | ||||
-rw-r--r-- | modules/user/user.pages.inc | 1 | ||||
-rw-r--r-- | modules/user/user.test | 18 |
3 files changed, 20 insertions, 1 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index 1b4f86988..5dcd203f1 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -2195,7 +2195,7 @@ function user_login_final_validate($form, &$form_state) { } } else { - form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password')))); + form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password', array('query' => array('name' => $form_state['values']['name'])))))); watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_state['values']['name'])); } } diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc index 29fe6cf4d..4cdbc40fa 100644 --- a/modules/user/user.pages.inc +++ b/modules/user/user.pages.inc @@ -36,6 +36,7 @@ function user_pass() { '#size' => 60, '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH), '#required' => TRUE, + '#default_value' => isset($_GET['name']) ? $_GET['name'] : '', ); // Allow logged in users to request this also. if ($user->uid > 0) { diff --git a/modules/user/user.test b/modules/user/user.test index 3e533abf8..c60f9c533 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -501,6 +501,24 @@ class UserPasswordResetTestCase extends DrupalWebTestCase { $this->drupalGet("user/reset/$account->uid/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login)); $this->assertText(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'), 'Expired password reset request rejected.'); } + + /** + * Prefill the text box on incorrect login via link to password reset page. + */ + function testUserPasswordTextboxFilled() { + $this->drupalGet('user/login'); + $edit = array( + 'name' => $this->randomName(), + 'pass' => $this->randomName(), + ); + $this->drupalPost('user', $edit, t('Log in')); + $this->assertRaw(t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', + array('@password' => url('user/password', array('query' => array('name' => $edit['name'])))))); + unset($edit['pass']); + $this->drupalGet('user/password', array('query' => array('name' => $edit['name']))); + $this->assertFieldByName('name', $edit['name'], 'User name found.'); + } + } /** |