Verified Commit 981921d8 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3181647 by ultimike, guiu.rocafort.ferrer, tobiasb, ilgnerfagundes,...

Issue #3181647 by ultimike, guiu.rocafort.ferrer, tobiasb, ilgnerfagundes, prudloff, jurgenhaas, guzmanb, maxime.rffd, hexaki, samuel_orhan, rauch, guiu.rocafort.ferrer, mullzk, binnythomas: Add autocomplete attributes on login form and password reset form
parent c9ced83e
Loading
Loading
Loading
Loading
Loading
+4
Changes for core/modules/user/src/Form/UserLoginForm.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
        'autocapitalize' => 'none',
        'spellcheck' => 'false',
        'autofocus' => 'autofocus',
        'autocomplete' => 'username',
      ],
    ];

@@ -123,6 +124,9 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      '#title' => $this->t('Password'),
      '#size' => 60,
      '#required' => TRUE,
      '#attributes' => [
        'autocomplete' => 'current-password',
      ],
    ];

    $form['actions'] = ['#type' => 'actions'];
+1
Changes for core/modules/user/src/Form/UserPasswordForm.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
        'autocapitalize' => 'off',
        'spellcheck' => 'false',
        'autofocus' => 'autofocus',
        'autocomplete' => 'username',
      ],
    ];
    // Allow logged in users to request this also.
+11
Changes for core/modules/user/tests/src/Functional/UserLoginTest.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -343,4 +343,15 @@ public function resetUserPassword($user) {
    $this->submitForm([], 'Log in');
  }

  /**
   * Tests that user login form has the autocomplete attributes.
   */
  public function testAutocompleteHtmlAttributes() {
    $this->drupalGet('user/login');
    $name_field = $this->getSession()->getPage()->findField('name');
    $pass_field = $this->getSession()->getPage()->findField('pass');
    $this->assertEquals('username', $name_field->getAttribute('autocomplete'));
    $this->assertEquals('current-password', $pass_field->getAttribute('autocomplete'));
  }

}
+9
Changes for core/modules/user/tests/src/Functional/UserPasswordResetTest.php: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -642,4 +642,13 @@ public function testResetImpersonation() {
    $this->assertSession()->pageTextContains('You have tried to use a one-time login link that has either been used or is no longer valid. Request a new one using the form below.');
  }

  /**
   * Test the autocomplete attribute is present.
   */
  public function testResetFormHasAutocompleteAttribute() {
    $this->drupalGet('user/password');
    $field = $this->getSession()->getPage()->findField('name');
    $this->assertEquals('username', $field->getAttribute('autocomplete'));
  }

}