Commit 666f423e authored by alexpott's avatar alexpott

Issue #2131849 by rpayanm, jmarkel, Shyamala: User password reset form button text is wrong

parent 76cf704a
......@@ -104,7 +104,7 @@ function testSiteMaintenance() {
$edit = array(
'name' => $this->user->getUsername(),
);
$this->drupalPostForm('user/password', $edit, t('Email new password'));
$this->drupalPostForm('user/password', $edit, t('Submit'));
$mails = $this->drupalGetMails();
$start = strpos($mails[0]['body'], 'user/reset/'. $this->user->id());
$path = substr($mails[0]['body'], $start, 66 + strlen($this->user->id()));
......
......@@ -134,8 +134,16 @@ public function form(array $form, FormStateInterface $form_state) {
if (!$pass_reset) {
$protected_values['mail'] = $form['account']['mail']['#title'];
$protected_values['pass'] = $this->t('Password');
$request_new = $this->l($this->t('Request new password'), new Url('user.pass', array(), array('attributes' => array('title' => $this->t('Request new password via email.')))));
$current_pass_description = $this->t('Required if you want to change the %mail or %pass below. !request_new.', array('%mail' => $protected_values['mail'], '%pass' => $protected_values['pass'], '!request_new' => $request_new));
$request_new = $this->l($this->t('Reset your password'), new Url('user.pass',
array(), array('attributes' => array('title' => $this->t('Send password reset instructions via e-mail.'))))
);
$current_pass_description = $this->t('Required if you want to change the %mail or %pass below. !request_new.',
array(
'%mail' => $protected_values['mail'],
'%pass' => $protected_values['pass'],
'!request_new' => $request_new,
)
);
}
// The user must enter their current password to change to a new one.
......
......@@ -92,15 +92,20 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['name']['#value'] = $user->getEmail();
$form['mail'] = array(
'#prefix' => '<p>',
'#markup' => $this->t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the email.', array('%email' => $user->getEmail())),
'#markup' => $this->t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the email.', array('%email' => $user->getEmail())),
'#suffix' => '</p>',
);
}
else {
$form['mail'] = array(
'#prefix' => '<p>',
'#markup' => $this->t('Password reset instructions will be sent to your registered e-mail address.'),
'#suffix' => '</p>',
);
$form['name']['#default_value'] = $this->getRequest()->query->get('name');
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Email new password'));
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit'));
return $form;
}
......
......@@ -55,9 +55,9 @@ public function build() {
),
)));
}
$items['request_password'] = \Drupal::l(t('Request new password'), new Url('user.pass', array(), array(
$items['request_password'] = \Drupal::l(t('Reset your password'), new Url('user.pass', array(), array(
'attributes' => array(
'title' => t('Request new password via email.'),
'title' => t('Send password reset instructions via e-mail.'),
'class' => array('request-password-link'),
),
)));
......
......@@ -131,7 +131,7 @@ function testAccountPageTitles() {
$this->assertTitle('Create new account' . $title_suffix, "Page title of /user/register is 'Create new account' for anonymous users.");
$this->drupalGet('user/password');
$this->assertTitle('Request new password' . $title_suffix, "Page title of /user/register is 'Request new password' for anonymous users.");
$this->assertTitle('Reset your password' . $title_suffix, "Page title of /user/register is 'Reset your password' for anonymous users.");
// Check the page title for registered users is "My Account" in menus.
$this->drupalLogin($this->drupalCreateUser());
......
......@@ -63,14 +63,14 @@ function testUserPasswordReset() {
$this->drupalGet('user/password');
$edit = array('name' => $this->randomMachineName(32));
$this->drupalPostForm(NULL, $edit, t('Email new password'));
$this->drupalPostForm(NULL, $edit, t('Submit'));
$this->assertText(t('Sorry, @name is not recognized as a username or an email address.', array('@name' => $edit['name'])), 'Validation error message shown when trying to request password for invalid account.');
$this->assertEqual(count($this->drupalGetMails(array('id' => 'user_password_reset'))), 0, 'No email was sent when requesting a password for an invalid account.');
// Reset the password by username via the password reset page.
$edit['name'] = $this->account->getUsername();
$this->drupalPostForm(NULL, $edit, t('Email new password'));
$this->drupalPostForm(NULL, $edit, t('Submit'));
// Verify that the user was sent an email.
$this->assertMail('to', $this->account->getEmail(), 'Password email sent to user.');
......@@ -109,7 +109,7 @@ function testUserPasswordReset() {
// Count email messages before to compare with after.
$before = count($this->drupalGetMails(array('id' => 'user_password_reset')));
$edit = array('name' => $this->account->getEmail());
$this->drupalPostForm(NULL, $edit, t('Email new password'));
$this->drupalPostForm(NULL, $edit, t('Submit'));
$this->assertTrue( count($this->drupalGetMails(array('id' => 'user_password_reset'))) === $before + 1, 'Email sent when requesting password reset using email address.');
// Create a password reset link as if the request time was 60 seconds older than the allowed limit.
......
......@@ -21,7 +21,7 @@ user.register:
user.pass:
route_name: user.pass
base_route: user.page
title: 'Request new password'
title: 'Reset your password'
# Other authentication methods may add pages below user/login/.
user.login:
route_name: user.login
......
......@@ -119,7 +119,7 @@ user.pass:
path: '/user/password'
defaults:
_form: '\Drupal\user\Form\UserPasswordForm'
_title: 'Request new password'
_title: 'Reset your password'
requirements:
_access: 'TRUE'
options:
......
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