Skip to content
Snippets Groups Projects
Commit b8abe391 authored by Alex Pott's avatar Alex Pott
Browse files

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
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment