diff -u b/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php --- b/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -59,7 +59,6 @@ * links = { * "canonical" = "/user/{user}", * "edit-form" = "/user/{user}/edit", - * "edit-pass-form" = "/user/{user}/edit-pass", * "edit-email-form" = "/user/{user}/edit-email", * "cancel-form" = "/user/{user}/cancel", * "collection" = "/admin/people", diff -u b/core/modules/user/src/Form/UserEmailChangeForm.php b/core/modules/user/src/Form/UserEmailChangeForm.php --- b/core/modules/user/src/Form/UserEmailChangeForm.php +++ b/core/modules/user/src/Form/UserEmailChangeForm.php @@ -13,7 +13,7 @@ /** * {@inheritdoc} - * + * * Removing base form id to avoid unapplicable hooks from contrib modules. */ public function getBaseFormId() { only in patch2: unchanged: --- a/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php +++ b/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php @@ -26,7 +26,7 @@ protected function setUp() { */ public function testShortcutPageLocalTasks($route) { $tasks = [ - 0 => ['shortcut.set_switch', 'entity.user.canonical', 'entity.user.edit_form'], + 0 => ['shortcut.set_switch', 'entity.user.canonical', 'entity.user.edit_collection'], ]; $this->assertLocalTasks($route, $tasks); } @@ -37,7 +37,7 @@ public function testShortcutPageLocalTasks($route) { public function getShortcutPageRoutes() { return [ ['entity.user.canonical'], - ['entity.user.edit_form'], + ['entity.user.edit_collection'], ['shortcut.set_switch'], ]; } only in patch2: unchanged: --- a/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php +++ b/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php @@ -84,7 +84,7 @@ public function testDateTimezone() { $this->drupalLogin($test_user); // Set up the user with a different timezone than the site. - $edit = ['mail' => $test_user->getEmail(), 'timezone' => 'Asia/Manila']; + $edit = ['timezone' => 'Asia/Manila']; $this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save')); // Reload the user and reset the timezone in AccountProxy::setAccount(). only in patch2: unchanged: --- a/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseFilledTest.php +++ b/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseFilledTest.php @@ -154,7 +154,7 @@ public function testUpdatedSite() { $this->drupalGet('admin/people'); $this->assertText('usuario_test'); $this->assertText('drupal'); - $this->drupalGet('user/1/edit'); + $this->drupalGet('user/1/edit-email'); $this->assertRaw('drupal@example.com'); // Make sure the content view works. only in patch2: unchanged: --- a/core/modules/system/tests/src/Functional/Update/UpdatePathTestBaseFilledTest.php +++ b/core/modules/system/tests/src/Functional/Update/UpdatePathTestBaseFilledTest.php @@ -156,7 +156,7 @@ public function testUpdatedSite() { $this->drupalGet('admin/people'); $this->assertText('usuario_test'); $this->assertText('drupal'); - $this->drupalGet('user/1/edit'); + $this->drupalGet('user/1/edit-email'); $this->assertRaw('drupal@example.com'); // Make sure the content view works. only in patch2: unchanged: --- a/core/modules/user/tests/src/Functional/UserEditTest.php +++ b/core/modules/user/tests/src/Functional/UserEditTest.php @@ -40,38 +40,42 @@ public function testUserEdit() { $this->assertSession()->titleEquals(strip_tags($user1->getDisplayName()) . ' | Drupal'); // Check that filling out a single password field does not validate. + $this->drupalGet('user/' . $user1->id() . "/edit-pass"); $edit = []; $edit['pass[pass1]'] = ''; $edit['pass[pass2]'] = $this->randomMachineName(); - $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); + $this->drupalPostForm("user/" . $user1->id() . "/edit-pass", $edit, t('Change Password')); $this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.'); $edit['pass[pass1]'] = $this->randomMachineName(); $edit['pass[pass2]'] = ''; - $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); + $this->drupalPostForm("user/" . $user1->id() . "/edit-pass", $edit, t('Change Password')); $this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.'); // Test that the error message appears when attempting to change the mail or // pass without the current password. - $edit = []; - $edit['mail'] = $this->randomMachineName() . '@new.example.com'; - $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); - $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Email')])); - - $edit['current_pass'] = $user1->passRaw; - $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); - $this->assertRaw(t("The changes have been saved.")); // Test that the user must enter current password before changing passwords. $edit = []; $edit['pass[pass1]'] = $new_pass = $this->randomMachineName(); $edit['pass[pass2]'] = $new_pass; - $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); + $this->drupalPostForm("user/" . $user1->id() . "/edit-pass", $edit, t('Change Password')); $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Password')])); // Try again with the current password. $edit['current_pass'] = $user1->passRaw; - $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); + $this->drupalPostForm("user/" . $user1->id() . "/edit-pass", $edit, t('Change Password')); + $this->assertRaw(t("The changes have been saved.")); + + // Test that the user must enter current password before changing email. + $this->drupalGet('user/' . $user1->id() . "/edit-email"); + $edit = []; + $edit['mail'] = $this->randomMachineName() . '@new.example.com'; + $this->drupalPostForm("user/" . $user1->id() . "/edit-email", $edit, t('Save')); + $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Email')])); + + $edit['current_pass'] = $user1->passRaw; + $this->drupalPostForm("user/" . $user1->id() . "/edit-email", $edit, t('Save')); $this->assertRaw(t("The changes have been saved.")); // Make sure the changed timestamp is updated. @@ -131,7 +135,7 @@ public function testUserWith0Password() { $user1 = $this->drupalCreateUser([]); $edit = ['pass[pass1]' => '0', 'pass[pass2]' => '0']; - $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); + $this->drupalPostForm("user/" . $user1->id() . "/edit-pass", $edit, t('Save')); $this->assertRaw(t("The changes have been saved.")); } @@ -147,7 +151,7 @@ public function testUserWithoutEmailEdit() { // This user has no email address. $user1->mail = ''; $user1->save(); - $this->drupalPostForm("user/" . $user1->id() . "/edit", ['mail' => ''], t('Save')); + $this->drupalPostForm("user/" . $user1->id() . "/edit-email", ['mail' => ''], t('Save')); $this->assertRaw(t("The changes have been saved.")); } only in patch2: unchanged: --- a/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php +++ b/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php @@ -85,15 +85,18 @@ public function testLocalUserCreation() { $this->drupalLogin($admin_user); $this->drupalGet($user_edit); $this->assertOptionSelected("edit-preferred-langcode", $langcode, 'Language selector is accessible and correct language is selected.'); + $this->drupalPostForm($user_edit, $edit, t('Save')); // Set passRaw so we can log in the new user. + $user_edit_pass = $langcode . '/user/' . $user->id() . '/edit-pass'; + $this->drupalGet($user_edit_pass); $user->passRaw = $this->randomMachineName(10); $edit = [ 'pass[pass1]' => $user->passRaw, 'pass[pass2]' => $user->passRaw, ]; - $this->drupalPostForm($user_edit, $edit, t('Save')); + $this->drupalPostForm($user_edit_pass, $edit, t('Change Password')); $this->drupalLogin($user); $this->drupalGet($user_edit); only in patch2: unchanged: --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -107,7 +107,7 @@ public function testUserPasswordReset() { // Check successful login. $this->drupalPostForm(NULL, NULL, t('Log in')); $this->assertLink(t('Log out')); - $this->assertTitle(t('@name | @site', ['@name' => $this->account->getAccountName(), '@site' => $this->config('system.site')->get('name')]), 'Logged in using password reset link.'); + $this->assertTitle(t('Change password | @site', ['@site' => $this->config('system.site')->get('name')]), 'Logged in using password reset link.'); // Change the forgotten password. $password = user_password(); @@ -252,7 +252,7 @@ public function testUserPasswordResetLoggedIn() { // Change the password. $password = user_password(); $edit = ['pass[pass1]' => $password, 'pass[pass2]' => $password]; - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm(NULL, $edit, t('Change Password')); $this->assertText(t('The changes have been saved.'), 'Password changed.'); // Logged in users should not be able to access the user.reset.login or the only in patch2: unchanged: --- a/core/modules/user/tests/src/Functional/UserTimeZoneTest.php +++ b/core/modules/user/tests/src/Functional/UserTimeZoneTest.php @@ -64,7 +64,6 @@ public function testUserTimeZone() { // Change user time zone to Santiago time. $edit = []; - $edit['mail'] = $web_user->getEmail(); $edit['timezone'] = 'America/Santiago'; $this->drupalPostForm("user/" . $web_user->id() . "/edit", $edit, t('Save')); $this->assertText(t('The changes have been saved.'), 'Time zone changed to Santiago time.'); only in patch2: unchanged: --- a/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php +++ /dev/null @@ -1,129 +0,0 @@ -drupalCreateUser(); - - // Activate user by logging in. - $this->drupalLogin($account); - - $this->account = User::load($account->id()); - $this->account->pass_raw = $account->pass_raw; - $this->drupalLogout(); - - // Set the last login time that is used to generate the one-time link so - // that it is definitely over a second ago. - $account->login = REQUEST_TIME - mt_rand(10, 100000); - Database::getConnection()->update('users_field_data') - ->fields(['login' => $account->getLastLoginTime()]) - ->condition('uid', $account->id()) - ->execute(); - } - - /** - * Tests password reset functionality with an AJAX form. - * - * Make sure the ajax request from uploading a user picture does not - * invalidate the reset token. - */ - public function testUserPasswordResetWithAdditionalAjaxForm() { - $this->drupalGet(Url::fromRoute('user.reset.form', ['uid' => $this->account->id()])); - - // Try to reset the password for an invalid account. - $this->drupalGet('user/password'); - - // Reset the password by username via the password reset page. - $edit['name'] = $this->account->getAccountName(); - $this->drupalPostForm(NULL, $edit, t('Submit')); - - $resetURL = $this->getResetURL(); - $this->drupalGet($resetURL); - - // Login - $this->drupalPostForm(NULL, NULL, t('Log in')); - - // Generate file. - $image_file = current($this->drupalGetTestFiles('image')); - $image_path = \Drupal::service('file_system')->realpath($image_file->uri); - - // Upload file. - $this->getSession()->getPage()->attachFileToField('Picture', $image_path); - $this->assertSession()->waitForButton('Remove'); - - // Change the forgotten password. - $password = user_password(); - $edit = ['pass[pass1]' => $password, 'pass[pass2]' => $password]; - $this->drupalPostForm(NULL, $edit, t('Save')); - - // Verify that the password reset session has been destroyed. - $this->drupalPostForm(NULL, $edit, t('Save')); - // Password needed to make profile changes. - $this->assertSession()->pageTextContains("Your current password is missing or incorrect; it's required to change the Password."); - } - - /** - * Retrieves password reset email and extracts the login link. - */ - public function getResetURL() { - // Assume the most recent email. - $_emails = $this->drupalGetMails(); - $email = end($_emails); - $urls = []; - preg_match('#.+user/reset/.+#', $email['body'], $urls); - - return $urls[0]; - } - -} only in patch2: unchanged: --- a/core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php +++ b/core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php @@ -76,44 +76,51 @@ public function testUserEditForm() { // Install the router table and then rebuild. \Drupal::service('router.builder')->rebuild(); + // Profile form. $form = $this->buildAccountForm('default'); + // Verify that autocomplete is off on name field. + $this->assertIdentical($form['account']['name']['#attributes']['autocomplete'], 'off', "'$key' field: 'autocomplete' attribute is 'off'."); + + // Change email form. + $form = $this->buildAccountForm('email'); + // Verify name and pass field order. $this->assertFieldOrder($form['account']); // Verify that autocomplete is off on all account fields. - foreach (['mail', 'name', 'pass'] as $key) { + foreach (['mail', 'current_pass'] as $key) { $this->assertIdentical($form['account'][$key]['#attributes']['autocomplete'], 'off', "'$key' field: 'autocomplete' attribute is 'off'."); } } /** - * Asserts that the 'name' form element is directly before the 'pass' element. + * Asserts that the 'current_pass' form element is directly before the 'mail' element. * * @param array $elements * A form array section that contains the user account form elements. */ protected function assertFieldOrder(array $elements) { - $name_index = 0; - $name_weight = 0; - $pass_index = 0; - $pass_weight = 0; + $current_pass_index = 0; + $current_pass_weight = 0; + $mail_index = 0; + $mail_weight = 0; $index = 0; foreach ($elements as $key => $element) { - if ($key === 'name') { - $name_index = $index; - $name_weight = $element['#weight']; - $this->assertTrue($element['#sorted'], "'name' field is #sorted."); + if ($key === 'current_pass') { + $current_pass_index = $index; + $current_pass_weight = $element['#weight']; + $this->assertTrue($element['#sorted'], "'current_pass' field is #sorted."); } - elseif ($key === 'pass') { - $pass_index = $index; - $pass_weight = $element['#weight']; - $this->assertTrue($element['#sorted'], "'pass' field is #sorted."); + elseif ($key === 'mail') { + $mail_index = $index; + $mail_weight = $element['#weight']; + $this->assertTrue($element['#sorted'], "'mail' field is #sorted."); } $index++; } - $this->assertEqual($name_index, $pass_index - 1, "'name' field ($name_index) appears before 'pass' field ($pass_index)."); - $this->assertTrue($name_weight < $pass_weight, "'name' field weight ($name_weight) is smaller than 'pass' field weight ($pass_weight)."); + $this->assertEqual($current_pass_index, $mail_index - 1, "'current_pass' field ($current_pass_index) appears before 'mail' field ($mail_index)."); + $this->assertTrue($current_pass_weight < $mail_weight, "'current_pass' field weight ($current_pass_weight) is smaller than 'mail' field weight ($mail_weight)."); } /** only in patch2: unchanged: --- a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php +++ b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php @@ -67,7 +67,7 @@ public function getUserLoginRoutes() { */ public function testUserPageLocalTasks($route, $subtask = []) { $tasks = [ - 0 => ['entity.user.canonical', 'entity.user.edit_form'], + 0 => ['entity.user.canonical', 'entity.user.edit_collection'], ]; if ($subtask) { $tasks[] = $subtask; @@ -81,7 +81,7 @@ public function testUserPageLocalTasks($route, $subtask = []) { public function getUserPageRoutes() { return [ ['entity.user.canonical'], - ['entity.user.edit_form'], + ['entity.user.edit_collection'], ]; }