Using Drupal 7.14 - when the checkbox 'Force password change on next login' is ticked, it is impossible to get out of the forced password change loop. Even if a user tries to change their password, they are instead shown the same form twice on one page, still asking for password change. Even if they uncheck the box and then change their password, it doesnt seem to take.
Also, if the admin (user/1) logs in and tries to uncheck the 'Force password change on next login' box for that user, it does not work. The profile settings are saved, but then when the admin inspects the profile again, the box is still checked.
This appears to happen after setting this as a global rule for all of a certain role at /admin/config/people/password_policy/password_change
The only way I've been able to fix this was by uninstalling the module completely and then re-enabling it.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | 1623138-password-policy-force-change-2.patch | 777 bytes | acbramley |
| #25 | 1623138-password-policy-force-change.patch | 946 bytes | acbramley |
| #9 | password_policy-force_change_loop-1623138-9.patch | 3.02 KB | erikwebb |
Comments
Comment #1
erikwebb commentedMy guess is that their UID is in the
{password_policy_force_change}table twice. After trying to change that user's password twice, could you attach the database table that you have? Use querySELECT * FROM password_policy_force_change WHERE uid=<uid>\GComment #2
pandabrand commentedI am having the same issue, the user is not in the password_policy_force_change twice. I have checked. Although my scenario is different. users were being constantly blocked so I took one and updated the last password_policy_history entry to have the created time to now. I could then unblock them but now whenever that user updates the password, it will say that it updated the password but then any attempt to leave that page will result in the error 'Your password has expired. You must change your password to proceed on the site'.
When I check the DB the force_change is not on so I assuming this has something to do with how the history table is checking/updating this information.
Comment #3
pandabrand commentedActually looking at the account array the 'force_password_change' seems to set to '1' all the time.
Comment #4
erikwebb commented@pandabrand: So you're seeing the database doesn't appear to be setting this, but rather code?
Comment #5
dags commentedI don't have any new information but I can confirm that I've experienced this issue exactly as brantwynn described in the summary.
Comment #6
nicodv commentedSame here, had to stop using it obviously... a pitty
Comment #7
scott.whittaker commentedI had the same issue. I think it's because of the hard-coded constraint that the new password must be different from the current password in password_policy_user_update:
Which would explain why it worked for one of my users, but not the other one. The restriction kind of makes sense because we are forcing the user to change their password, but in my case the only reason we are forcing the change is to enforce more secure passwords. If the user's old password is already secure then they should be able to reuse it.
The enforcement should be optional configuration.
Also I suspect the Force password change on next login checkbox should probably be a hidden field since ticking or unticking the checkbox has absolutely no effect whether the passwords are the same or not.
Comment #8
erikwebb commentedI think it's common behavior that a forced password change should require users to create a new password.
On the other hand, I suppose we could remove the check for a different password and rely on the history constraint to kick-in if you don't want the user to repeat a password. That may solve both of these problems.
Comment #9
erikwebb commentedComment #10
erikwebb commentedComment #12
erikwebb commentedComment #13
erikwebb commented#9: password_policy-force_change_loop-1623138-9.patch queued for re-testing.
Comment #15
zd370 commented@erikweeb
Please comment out/remove the following line from your patch:
+ dsm('Change me!');Comment #16
jh81 commentedI'm having this problem. Does the latest version 7.x-1.3 fix this problem or do I need the patch.
Comment #17
erikwebb commented@jh81 - I haven't had a chance to fix the test problems and haven't received other patches, so there's nothing completed that has been included in the module yet.
(Changing priority back to major. This does not render the entire module unusable, just one feature.)
Comment #18
erikwebb commentedThis might have been fixed be partially solved by #1570122: Expired passwords stuck.
Could I get some new feedback on this issue?
Comment #19
acbramley commentedI've recently run into this issue with version 1.4 so the issue above doesn't seem to have fixed it.
I can actually replicate this by inserting a (uid, 1) pair into password_policy_force_change then logging in with that user, upon logging in you are presented with the " Your password has expired. You must change your password to proceed on the site." message and changing the password does not result in this being cleared. Eventually I get a page with the entire form duplicated on the page, I am only able to get rid of the message by updating the db table.
Comment #20
acbramley commentedThe issue is that $account in hook_user_update for some reason has force_password_change always set to 0.
EDIT: Confirmed by adding
Just above the first conditional in hook_user_update, this stopped the infinite "expiration"
Comment #21
erikwebb commentedThis is a similar problem to what we're trying to address here - #2008282: user_load in hook_init is not performant
Maybe we should be looking at a more general way to ensure our properties are added as early as possible.
Comment #22
acbramley commentedYeah or could we not directly query the db in hook_user_update for now as this is a pretty serious bug, I currently can't find what's causing it but the only way to fix it is manually altering the force_change table.
Comment #23
acbramley commentedThe cause of this issue is from hook_user_login when a user does not have an entry in the password_policy_history table. The user logs in and since they have not changed their password since the policy was enabled they get force_change set to 1. The user then attempts to update their password and because of the issues explained above the user is never able to get out of the infinite loop. Any db changes directly to the force_change table get overwritten upon next login.
EDIT: Furthermore, the password changes aren't even being saved into the history table. Debugging in the submit handler is showing it's not even running
EDIT 2: The save issue was caused by a pesky custom submit handler doing a drupal_goto that I was unaware of
Comment #24
acbramley commentedChanging to version 1.4 as --dev is behind stable...
Comment #25
acbramley commentedHere's a patch that fixes the user_update issue in any case.
Comment #26
lightweight commentedI can confirm that the same patch submitted by acbramley applies cleanly to 7.x-1.5, but it would be great if the maintainers of Password Policy would apply the patch as a bug fix for the next release.
Comment #27
dan_lennox commentedI'm currently still having this issue in 7.x-1.5. The patch in #25 doesn't seem to resolve the issue and the "loop" is still occurring.
Comment #28
acbramley commented@dan_lennox, can you please provide details of how to reproduce this issue from a fresh install using the patch in #25
Comment #29
acbramley commentedMy fix did not take into account that when a user is blocked by cron (i.e the password_policy_expiration table has a blocked timestamp and the password_policy_force_change table has force_change = 0) the $account->force_change property might be 0, but it is set to 1 on hook_user_load if the user has an expired password.
This means if the user hits the site when they are expired by cron, they are redirected to the user edit page subsequently when they save the new password the following check fails in hook_user_update() and the expiration is never deleted from the db.
As I've said above, the main issue here is that the $account object does not have the correct value for the force_change_password property when the hook initiates. Strangely enough $account->original->force_change_password seems to be correct. Patch attached. I've tested with expiring users and forcing them to change passwords and both have correctly work and been able to be unblocked by changing the password :)
Comment #30
aaronott commentedThe patch in #29 works for me.
Thanks!
Comment #31
jami3z commentedPatch #29 seems to have fixed the looping issue for me, but I still get the duplicate page/form displayed as described in the original description.
Comment #32
adchavez commentedPatch #29 solved it for me as well with Password Policy 7.x-1.5.
Comment #34
erikwebb commentedLooks like we have consensus!
Comment #35
erikwebb commented