Problem/Motivation

Clicking on the forgot password link it generate one time use password reset link which is send via mail. After clicking on the link we can see that Password and confirm password are not mandatory fields. Which misguides user at UX and functionality level.

Actual Result - The one time password generator link which has Password and confirm password is not compulsory.

Expected Result - When user follows one time link to set the password, 'Password' and 'Confirm Password' fields should be mandatory fields.

Steps to reproduce

  1. Install a new Drupal instance
  2. Installed Development Environment module, which allowed me to test the mail
  3. Created new user
  4. Reviewed site log report for One time link
  5. Click on one time login link
  6. Now View that password and required password field is not compulsory.

Proposed resolution

When user follows one time link to set the password, 'Password' and 'Confirm Password' fields should be mandatory fields.

Remaining tasks

Update issue summary
Review patch

User interface changes

Before
Actual result
After
Expected result

CommentFileSizeAuthor
#56 interdiff52-56.txt1.96 KBaarti zikre
#56 2855328_56.patch2.01 KBaarti zikre
#52 2855328_52.patch2.13 KBasad_ahmed
#47 2855328before patch.png60.53 KBaarti zikre
#47 2855328 after patch.png60.12 KBaarti zikre
#40 interdiff_40-Fail-40.txt2.13 KBdanflanagan8
#40 2855328-40.patch2.13 KBdanflanagan8
#40 2855328-40-FAIL.patch872 bytesdanflanagan8
#39 after--patch--pic.png23.91 KBvikashsoni
#39 before--patch--pic.png47.06 KBvikashsoni
#33 users-onetime_login_bug_fixes-2855328-33.patch1.27 KBanushrikumari
#25 reset_success_after.png38.14 KBPancho
#25 reset_failure_after.png39.9 KBPancho
#25 reset_form_after.png39.42 KBPancho
#25 reset_form_before.png39.11 KBPancho
#25 2855328_4-22_diff.txt1.81 KBPancho
#25 users-onetime_login_bug_fixes-2855328-22.patch1.15 KBPancho
#13 users-onetime_login_bug_fixes-2855328-13-7.patch1.02 KBashwinparmar
#6 users-onetime_login_bug_fixes-2855328-4.patch927 bytessourabh.singhal
#4 users-onetime_login_bug_fixes-2855328-4.patch927 bytessourabh.singhal
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Archana.Phatangare created an issue. See original summary.

cilefen’s picture

Before adding tags read the issue tag guidelines.

sourabh.singhal’s picture

Assigned: Unassigned » sourabh.singhal
sourabh.singhal’s picture

Assigned: sourabh.singhal » Unassigned
Status: Active » Needs review
FileSize
927 bytes

Hi,

I have created patch for this. Please review.

Find attached patch.

Thanks
Sourdrup

Status: Needs review » Needs work

The last submitted patch, 4: users-onetime_login_bug_fixes-2855328-4.patch, failed testing.

sourabh.singhal’s picture

Adding patch again. Please review

sourabh.singhal’s picture

Status: Needs work » Needs review

The last submitted patch, 4: users-onetime_login_bug_fixes-2855328-4.patch, failed testing.

cilefen’s picture

At a glance, I think #4 failed because it makes the field required in every possible usage of the form. It seems you uploaded an identical patch in #6. You should read the test results to see what happened.

sourabh.singhal’s picture

Hi cilefen,

Yes, it is the identical patch and I have already went through the test results and found that there is no test case failure related to my patch. I have just added single line of code which works only in a condition when one time login link is used for setting up the password.
I have also tested the whole process and flow of user registration and it works perfectly fine as expected.

Thanks
Sourdrup

cilefen’s picture

I do not agree. Some failures are related to this change.

cilefen’s picture

Status: Needs review » Needs work
ashwinparmar’s picture

I have updated my patch which will help you when user reset password from email link (With URL Token), Its mandatory to provide password and confirm password.

tameeshb’s picture

Status: Needs work » Needs review

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

ideaseed’s picture

Issue tags: +Vienna2017

I am working on this issue at DrupalCon Vienna (mentored core sprints) with @sugaroverflow.

ideaseed’s picture

Steps to test this issue:
# Created a dev desktop site with appropriate verison: http://drupal-8-5-x-dev.dd:8083/
# Installed Development Environment module to allow me to test emails
# Created new user "jenn-test"
# Reviewed site log report for email sent to "jenn-test"
jenn-test,
A site administrator at Triage has created an account for you. You may now log in by clicking this link or copying and pasting it into your browser:
http://drupal-8-5-x-dev.dd:8083/user/reset/7/1506686934/BT9SI1QRBWWj6Nj8...
This link can only be used once to log in and will lead you to a page where you can set your password.
After setting your password, you will be able to log in at http://drupal-8-5-x-dev.dd:8083/user in the future using:
username: jenn-test
password: Your password
-- Triage team
# Copied and pasted the link to a new incognito window in browser
# Clicked on login link (see screenshot)
# Observed the Password and Confirm Password fields are NOT showing as required, so this test fails.

ideaseed’s picture

Status: Needs review » Needs work

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.

Pancho’s picture

Version: 8.7.x-dev » 8.6.x-dev
Issue tags: +Needs tests

Bug fix goes to 8.6.x-dev. Also needs tests, including a test-only patch.

FiNeX’s picture

Hi, I've added an upgraded patch for 8.6.x-dev.

Instead of always setting the password required, this patch only require it on the reset password form after the one time login.

FiNeX’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 22: 2855328-require-pass-only-on-reset.patch, failed testing. View results

Pancho’s picture

[Dammit, crosspost. Still posting:]

Here's an updated patch, taking D7 patch #13 into account, with screenshots. Tests still needed.

Before:
before

After:
after

With no password being given:
failure

Password correctly given:
success

Pancho’s picture

Issue summary: View changes

Added expected/actual screenshots to IS.

Pancho’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Needs work » Needs review

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Sam152’s picture

Status: Needs review » Needs work

This is NW for tests.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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.

alternativo’s picture

Hi,
I'm using D8.9.3 and the problem is still there...
A new user that registers himself, receiving confirmation email after admin unblocked his account, opening the one-time link in the email, the user can avoid to set the password and go navigating on the site's link. thus not having a password for the future login.
It should be forced to set the password (and the other required fields) before to let him navigate the site.
Are there any updates on that?

thanks

anushrikumari’s picture

Status: Needs work » Needs review
FileSize
1.27 KB

Rerolled patch for 9.1.x

alternativo’s picture

Hi,
thanks @anushrikumari for the very fast reply...the patch for me work well (drupal 8.9.3)!
But my issue is another, and maybe I was not so clear...The problem is that even if the new user do not fill the password field (the now is required with the patch) and do not edit/save the profile, he can starts to navigate the site's links, without having set a password to login again: if he logouts, to login again he will have to do password recovery procedure. I think he should be forced to save the profile (and so create the password), and not to have the possibility to open other links in the site.

Maybe it's not so easy to do...:/

tanubansal’s picture

Tested #33 for the below mentioned steps :
Admin sends invite to user by assigning role and notifying user to through an email
User will receive an email on his email address with one time link to log in to the site
User have to click on 'Log in' button on first screen
Now on next screen, user will have 'password' and 'confirm password' fields , but if user clicks 'Save' button without entering 'password' and 'confirm password', drupal allows to save the form as the fields are not mandatory

Works fine for me on 9.1

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Archana.Phatangare’s picture

vikashsoni’s picture

Applied patch #33 working fine for ref --- sharing screenshot

Step to reproduce ---
--- Install drupal-9.3.x-dev
--- Create a test user
--- generate one time login link
--- See there is option password and confirm password that is not required
--- Now apply the patch rebuild cache and see password and confirm password is mandatory field

danflanagan8’s picture

Here's a fail test and a mash-up of #33 with the fail test. The interdiff shows the diff between these two patches, which is equivalent to the fix in #33.

The last submitted patch, 40: 2855328-40-FAIL.patch, failed testing. View results

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gtoyloy18’s picture

The #40 2855328-40.patch file work correctly.
Thanks.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Andrew Answer’s picture

Hello all, I created a simple module Min Password for fixing this issue. You can set up password length by this module, and users can't save zero-length passwords more.

aarti zikre’s picture

Assigned: Unassigned » aarti zikre
aarti zikre’s picture

#45 that's great stuff
Verified patch for Drupal 9.5.x dev version
https://www.drupal.org/files/issues/2021-09-30/2855328-40.patch

Testing Steps:
* Install a new Drupal instance
* Installed Development Environment module, which allowed me to test the mail
* Created new user "azikre"
* Reviewed site log report for email sent to "azikre"
* Click on one time login link

Problem:
Password and confirm password fields are not compulsory

Test Result:
Verified that after applying patch both the fields are set as required

Refer SS
Before apply Patch
before patch
After apply Patch
2022-07-15/2855328 after patch.png
Mail Details:
Time: 07/15/2022 - 13:27

Recipient: test@gmail.com

Subject: An administrator created an account for you at test2
Body: zaarti, A site administrator at test2 has created an account for you. You may now log in by clicking this link or copying and pasting it into your browser: http://test2.lndo.site/user/reset/5/1657871870/T5se1wUGmXW-BlXYCHLE_L7Xn... This link can only be used once to log in and will lead you to a page where you can set your password. After setting your password, you will be able to log in at http://test2.lndo.site/user in the future using: username: zaarti password: Your password -- test2 team

Headers:Array

Test Result Pass
Can be move to RTBC

aarti zikre’s picture

Assigned: aarti zikre » Unassigned
Status: Needs review » Reviewed & tested by the community
quietone’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update, +Novice

@aarti zikre, thanks for the work on this issue.

A few more things need to be done before this is ready for a committer.

The issue summary is out of date. It is simplest to add the standard template and complete the sections. Also, the latest screenshots should be in the Issue summary for easy review. Adding tag. I've added the template but it still needs an update. This is suitable for a novice, adding tag.

This is testing on 9.3 instead of 9.5.x, changing version.

I don't see any code review. Looking now.

+++ b/core/modules/user/src/AccountForm.php
@@ -152,10 +152,13 @@ public function form(array $form, FormStateInterface $form_state) {
+        // If logged in via a one-time login link, the user may change their
+        // password without giving their current password. However, entering a
+        // new password is required in this case.
+        if ($form_state->get('user_pass_reset')) {
...
+        else {

I think the comment could be a lot simpler and clearer. What about this?

        // If logged in via a one-time login link entering a new password is
        // required and the user does not need to enter their current password.
asad_ahmed’s picture

I am working on this issue.

asad_ahmed’s picture

Assigned: Unassigned » asad_ahmed
asad_ahmed’s picture

Made changes as per #40, still needs issue summary update.

asad_ahmed’s picture

Assigned: asad_ahmed » Unassigned
aarti zikre’s picture

Issue summary: View changes
Status: Needs work » Needs review

IS updated

aarti zikre’s picture

Issue summary: View changes
aarti zikre’s picture

updated patch with comments

tiwariraj91929’s picture

Status: Needs review » Reviewed & tested by the community

patch comment updated as requested by #49.

idebr’s picture

Why should the password field be required after using the one-time login link?

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 56: 2855328_56.patch, failed testing. View results

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.