diff --git a/core/modules/user/src/AccountSettingsForm.php b/core/modules/user/src/AccountSettingsForm.php index cf11268..e59c2fa 100644 --- a/core/modules/user/src/AccountSettingsForm.php +++ b/core/modules/user/src/AccountSettingsForm.php @@ -210,7 +210,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); // These email tokens are shared for all settings, so just define // the list once to help ensure they stay in sync. - $email_token_help = $this->t('Available variables are: [site:name], [site:url], [user:name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].'); + $email_token_help = $this->t('Available variables are: [site:name], [site:url], [user:name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:mail-change-login-url], [user:cancel-url].'); $form['email_admin_created'] = array( '#type' => 'details', @@ -312,44 +312,44 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#rows' => 12, ); - $form['email_mail_change_notification'] = array( + $form['email_email_change_notification'] = array( '#type' => 'details', - '#title' => t('Email Change Notification'), + '#title' => t('Email change notification'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Edit the e-mail messages sent to users old mail address who change mail address.') . ' ' . $email_token_help, '#group' => 'email', '#weight' => 11, ); - $form['email_mail_change_notification']['user_mail_mail_change_notification_subject'] = array( + $form['email_email_change_notification']['user_email_change_notification_subject'] = array( '#type' => 'textfield', '#title' => t('Subject'), '#default_value' => $mail_config->get('mail_change_notification.subject'), '#maxlength' => 180, ); - $form['email_mail_change_notification']['user_mail_mail_change_notification_body'] = array( + $form['email_email_change_notification']['user_email_change_notification_body'] = array( '#type' => 'textarea', '#title' => t('Body'), '#default_value' => $mail_config->get('mail_change_notification.body'), '#rows' => 12, ); - $form['email_mail_change_verification'] = array( + $form['email_email_change_verification'] = array( '#type' => 'details', - '#title' => t('Email Change Verification'), + '#title' => t('Email change verification'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Edit the e-mail messages sent to users new mail address who change mail address.') . ' ' . $email_token_help, '#group' => 'email', '#weight' => 13, ); - $form['email_mail_change_verification']['user_mail_mail_change_verification_subject'] = array( + $form['email_email_change_verification']['user_email_change_verification_subject'] = array( '#type' => 'textfield', '#title' => t('Subject'), '#default_value' => $mail_config->get('mail_change_verification.subject'), '#maxlength' => 180, ); - $form['email_mail_change_verification']['user_mail_mail_change_verification_body'] = array( + $form['email_email_mail_change_verification']['user_email_change_verification_body'] = array( '#type' => 'textarea', '#title' => t('Body'), '#default_value' => $mail_config->get('mail_change_verification.body'), @@ -498,6 +498,10 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ->set('cancel_confirm.subject', $form_state->getValue('user_mail_cancel_confirm_subject')) ->set('password_reset.body', $form_state->getValue('user_mail_password_reset_body')) ->set('password_reset.subject', $form_state->getValue('user_mail_password_reset_subject')) + ->set('mail_change_notification.subject', $form_state->getValue('user_email_change_notification_subject')) + ->set('mail_change_notification.body', $form_state->getValue('user_email_change_notification_body')) + ->set('mail_change_verification.subject', $form_state->getValue('user_email_change_verification_subject')) + ->set('mail_change_verification.body', $form_state->getValue('user_email_change_verification_body')) ->set('register_admin_created.body', $form_state->getValue('user_mail_register_admin_created_body')) ->set('register_admin_created.subject', $form_state->getValue('user_mail_register_admin_created_subject')) ->set('register_no_approval_required.body', $form_state->getValue('user_mail_register_no_approval_required_body')) diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php index d453634..5b6b387 100644 --- a/core/modules/user/src/Controller/UserController.php +++ b/core/modules/user/src/Controller/UserController.php @@ -159,7 +159,7 @@ public function changeEmail($uid, $timestamp, $new_email, $hash) { $user = \Drupal::currentUser(); $account = $this->userData->get('user', $uid); - $timeout = 86400; + $timeout = 24 * 60 * 60; $current = $_SERVER['REQUEST_TIME']; if ($timestamp < $current) { diff --git a/core/modules/user/src/Tests/UserEditedOwnAccountTest.php b/core/modules/user/src/Tests/UserEditedOwnAccountTest.php index bee1a9b..49ebd03 100644 --- a/core/modules/user/src/Tests/UserEditedOwnAccountTest.php +++ b/core/modules/user/src/Tests/UserEditedOwnAccountTest.php @@ -10,12 +10,15 @@ use Drupal\simpletest\WebTestBase; /** - * Tests user edited own account can still log in. + * Tests the user edit form for the current user. * * @group user */ class UserEditedOwnAccountTest extends WebTestBase { + /** + * Tests user edited own account can still log in. + */ function testUserEditedOwnAccount() { // Change account setting 'Who can register accounts?' to Administrators // only. @@ -27,7 +30,8 @@ function testUserEditedOwnAccount() { // Change own username. $edit = array(); - $edit['name'] = $this->randomMachineName(); + $name = $this->randomMachineName(); + $edit['name'] = $name; $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save')); // Log out. @@ -36,5 +40,20 @@ function testUserEditedOwnAccount() { // Set the new name on the user account and attempt to log back in. $account->name = $edit['name']; $this->drupalLogin($account); + + // Set a new email address for the user account. + $new_email = $this->randomMachineName() . '@example.com'; + $edit = array( + 'current_pass' => $account->pass_raw, + 'mail' => $new_email, + ); + $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save')); + + $site_name = $this->config('system.site')->get('name'); + $user_mail = $this->drupalGetMails(array( + 'to' => $new_email, + 'subject' => "E-mail change information for $name at $site_name", + )); + $this->assertTrue(count($user_mail), 'A verification email was sent to the user.'); } } diff --git a/core/modules/user/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php index 16c43b4..9038f06 100644 --- a/core/modules/user/src/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php @@ -86,6 +86,7 @@ function testUserTokenReplacement() { // Generate login and cancel link. $tests = array(); $tests['[user:one-time-login-url]'] = user_pass_reset_url($account); + $tests['[user:mail-change-login-url]'] = user_change_mail_url($account); $tests['[user:cancel-url]'] = user_cancel_url($account); // Generate tokens with interface language.