$request_new=$this->l($this->t('Request new password'),newUrl('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'),newUrl('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.'),
$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.
$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.