When you have the autocomplete option enabled in Google Chrome and you edit a user profile, the 'E-MAIL ADDRESS' and 'NEW PASSWORD' fields are both prefilled. So Drupal thinks you want to change your password and throws an error: "Your current password is missing or incorrect; it's required to change the Password."

So you have to manually empty the 'NEW PASSWORD' field if you don't want to change your password. We can disable the autocompletion of this field using HTML attributes 'autocomplete=off'. That was already done for the existing password field but not for the new one.

I'll submit a patch in a minute.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jeff.maes’s picture

Status: Active » Needs review
FileSize
1.31 KB
attiks’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work
Issue tags: +Needs backport to D7

Needs to be fixed for Drupal 8 first

+++ b/modules/user/user.moduleundefined
@@ -1034,6 +1034,7 @@ function user_account_form(&$form, &$form_state) {
+	'#attributes' => array('autocomplete' => 'off'),

spacing error

jeff.maes’s picture

This version is for Drupal 8

jeff.maes’s picture

Status: Needs work » Needs review
attiks’s picture

Status: Needs review » Reviewed & tested by the community

Patch is looking good and reason is good.

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Makes sense to me. Committed/pushed to 8.x, moving to 7.x for backport.

jeff.maes’s picture

Status: Patch (to be ported) » Needs review
FileSize
1.31 KB

Thanks for committing my patch. I've re-attached the D7 version (without the spacing error this time).

attiks’s picture

Status: Needs review » Reviewed & tested by the community

Assuming testbot will approve the patch, this is looking good.

chx’s picture

Status: Reviewed & tested by the community » Needs review

I get it why we dont want autofill on password, yes but why the username? Neither the issue title nor the summary tells me.

attiks’s picture

If I understand correctly username is a problem if you create a new user, it gets filled with your own username, but you're right summary talks about email and new password, patch is indeed about email and username.

@jeff.maes can you clarify and change the summary?

jeff.maes’s picture

A little more explanation:

When you actually change your password on the user/*/edit page, Chrome asks if you would like to update your existing password for that website. When you select 'Yes', it saves the combination of the e-mailaddress/password instead of username/password. That results in the autocompletion of the e-mailaddress/password on the user/*/edit page. So that's the reason why I added automplete=off on both fields.

Today, I did some retesting on the latest DEV and still had the autocomplete issues... After updating my Chrome browser to the latest version (19), all the autocomplete issues were gone.

So, what do you think? Do we need to explicitly mention the browsers to skip the autocompletion and include this patch? Or is this the complete responsibility of the browser?

David_Rothstein’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

Yeah, something seems wrong here - the patch does look like it changed username/e-mail only but didn't touch any of the password fields (contrary to the issue title). I really can't see why we would prevent autocomplete on anything but a password field.

Related issue: #787876: Edit "My Account" fills the first password field

sun’s picture

Priority: Minor » Normal
Issue summary: View changes

The username/email mismatch is a separate problem that exists for a long time already. I just created an issue to fix that:

#2191785: Password managers are identifying/storing wrong username field when creating a user account

After noticing that in D8, my browser does not ask me to store my credentials at all anymore, I pickaxed the git log and found this issue.

The 'autocomplete=off' attribute seems to have been added to too many form elements here. Or perhaps more specifically, the changes were not limited to the case/condition of actually editing your own & existing user account.

As a result, the browser's autocompletion (+ password manager) is completely turned off for all incarnations of the user account form; i.e., in the registration form, the administrative user account creation form, the administrative edit form, and also the edit form.

Unless I misunderstood the purpose of this issue, the attribute should only have been added for the case of editing the own user account...

However, given the original topic starter, the committed change might have been unnecessary — the originally reported username/email autofilling mismatch is exactly what is being fixed in #2191785: Password managers are identifying/storing wrong username field when creating a user account

In light of that, I'm not sure whether we shouldn't roll back the patch in #3?

claudiu.cristea’s picture

mgifford’s picture

@sun, your patch https://drupal.org/files/issues/user.form_.22.patch addresses the username, but not the email.

$form['account']['mail'] = array(
      '#type' => 'email',
      '#title' => $this->t('E-mail address'),
      '#description' => $this->t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
      '#required' => !(!$account->getEmail() && $user->hasPermission('administer users')),
      '#default_value' => (!$register ? $account->getEmail() : ''),
      '#attributes' => array('autocomplete' => 'off'),
    );

@David_Rothstein - the password field doesn't autocomplete anyways. Least not on my quick mobile testing. If this is happening in some smart phones then we should look at explicitly. I don't think it's a problem anywhere other than the username/email fields.

sun’s picture

The revised/final patch in #2191785-25: Password managers are identifying/storing wrong username field when creating a user account now contains proper test coverage for this issue.

mgifford’s picture

With this:

+    // Verify that autocomplete is off on all account fields.
+    foreach (array('mail', 'name', 'pass') as $key) {
+      $this->assertIdentical($form['account'][$key]['#attributes']['autocomplete'], 'off', "'$key' field: 'autocomplete' attribute is 'off'.");
+    }

I see no reason not to roll back the patch in #3.

sun’s picture

Hm. The situation is a bit hairy. Technically, we could roll back the patch in #3 and redo it from scratch including tests, additionally accounting for the Safari issue in #15...

However, that would break #2191785: Password managers are identifying/storing wrong username field when creating a user account (which essentially reverts + re-implements already), so I'd personally prefer to simply move forward with that instead, and leave this issue for a possible backport only.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • catch committed 74d3fc2 on 8.3.x
    Issue #1525640 by jeff.maes: Fixed Disable autocompletion for email/...

  • catch committed 74d3fc2 on 8.3.x
    Issue #1525640 by jeff.maes: Fixed Disable autocompletion for email/...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • catch committed 74d3fc2 on 8.4.x
    Issue #1525640 by jeff.maes: Fixed Disable autocompletion for email/...

  • catch committed 74d3fc2 on 8.4.x
    Issue #1525640 by jeff.maes: Fixed Disable autocompletion for email/...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

  • catch committed 74d3fc2 on 9.1.x
    Issue #1525640 by jeff.maes: Fixed Disable autocompletion for email/...

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Version: 8.9.x-dev » 7.x-dev
Issue tags: +Bug Smash Initiative

So confusing!! The patch in #3 was committed and Fixed in 2012, and subsequently re-opened much later to discuss reverting. This didn't happen and there has not been any discussion in many years so I'm going to re-mark this Needs work and bump to 7.x for backport.