diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php index bd75e06..68c28bb 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPasswordResetTest.php @@ -108,4 +108,21 @@ public function getResetURL() { return $urls[0]; } + + /** + * Prefill the text box on incorrect login via link to password reset page. + */ + public function testUserResetPasswordTextboxFilled() { + $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. Have you forgotten your password?', + 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.'); + } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 710e56d..09e745a 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1372,7 +1372,7 @@ function user_login_final_validate($form, &$form_state) { } } else { - form_set_error('name', t('Sorry, unrecognized username or password. Have you forgotten your password?', array('@password' => url('user/password')))); + form_set_error('name', t('Sorry, unrecognized username or password. Have you forgotten your password?', 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/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 140b767..f3c0e01 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -38,6 +38,9 @@ function user_pass() { '#suffix' => '

', ); } + else { + $form['name']['#default_value'] = Drupal::Request()->query->get('foo'); + } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password'));