Commit b8abe391 authored by alexpott's avatar alexpott

Issue #1952196 by greggles, sandhya.m: Usability: if a user has just failed a...

Issue #1952196 by greggles, sandhya.m: Usability: if a user has just failed a login, default their username on password reset.
parent 1eb9af15
......@@ -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. <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.');
}
}
......@@ -1372,7 +1372,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']));
}
}
......
......@@ -38,6 +38,9 @@ function user_pass() {
'#suffix' => '</p>',
);
}
else {
$form['name']['#default_value'] = Drupal::Request()->query->get('name');
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment