Hello,
I know that "Password policies only apply to passwords set via user forms in the web interface".
But... I’ve installed Password policies. When a user (who forgets his password) wants to reset his password (following the link on the login page), he receives a link by email (password recovery link) . When he follows this link, he fills a form but the Password policies is not applied. It’s like it is not activated.
Is it normal behavior ? I thought that it was a form from web interface.
It works when I rest the password in the admin. I can see the plugin activated.
| Comment | File | Size | Author |
|---|---|---|---|
| #63 | password_policy-prlp-63.patch | 8.65 KB | wadator |
| #56 | password_policy-prlp-56.patch | 8.54 KB | wadator |
Issue fork password_policy-3078741
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
aohrvetpv commentedI believe password policies should apply in that case. I'll plan to investigate. Thanks for reporting the bug.
Comment #3
sébastien-frI’ve installed a Drupal clean install (8.7.6) and the module Password Policy works as expected, both for admin and authenticated user
So on the website I’m working on where the module is not working : I’m sure (I've tested on this clean install) it is because I’ve installed Simple Password Reset which skips the unnecessary and confusing one-time login form and I think Password policy is not applied.
Could you help me to investigate and find a solution ? I will check this ans ask Simple Password Reset developer too.
Comment #4
vacho commentedComment #5
vacho commentedThis first patch is only an approach to get the end solution.
The idea is to add the form elements to validate to form user_pass_reset, such as the module did for user_form and user_register_form
To get this patch finished, we need to implement correctly the ajax validation for the field "pass" at this time it is not working.
Comment #6
vacho commentedThis patch fix problem with $form['pass'] where this element not found at hook_form_FORM_ID_alter (password_policy_form_user_pass_reset_alter) but still not work correctly with ajax. At this time the function ajax is not calling.
Comment #7
vacho commentedThis patch is identical to 7 but for the dev branch. (with ajax issue still)
Comment #8
vacho commentedComment #9
andypostComment #10
andypostComment #11
jcnventuraMoving the module weight change to #2943105: Password policy and Password Reset Landing Page.
Also, I think I can make this patch smaller.
However, my main issue with the patch, is that I see the password_policy well enough already in the password reset form, so I have no idea why this would be needed.
Comment #12
jcnventuraWell, that didn't work. Main reason was that the _password_policy_constraints_table() function doesn't exist. After that came the fact that the user really is anonymous at this point (talking about the password reset form....).
Comment #13
jcnventuraAnd it still doesn't work if I patch prlp to validate the passwords. One final try at fixing this before I remove prlp from this site...
Comment #14
jcnventuraI was wondering what that 'dsu_security_validate' from @vacho's #7 patch was. It seems it's something from his particular project. There's more errors even removing that one line, and I'm giving up on getting password_policy and prlp to work together.
Comment #15
espurnesHi jcnventura,
dsu_security_validate is, indeed, part of another installation profile and that code shouldn't be there.
I've found that the problem seems related, but maybe not limited, to prlp and this issue #3143391: Password reset form validation allows non-matching passwords. It bypasses repeat password validation.
Have you managed to make password_policy + prlp work?
Update:
I see that the issue happens with password_policy 8.x-3.0-beta1. Downgrading to 8.x-3.0-alpha5 seems that solves the problem and form validates again.
Comment #16
jcnventuraWe uninstalled prlp.
Comment #17
amarlataFixed error after applying the patch #13.
Error: Call to undefined method Drupal\user\Form\UserPasswordResetForm::getEntity() in _password_policy_user_profile_form_submit() (line 319 of modules/contrib/password_policy_prev/password_policy.module).
_password_policy_user_profile_form_submit(Array, Object)
call_user_func_array('_password_policy_user_profile_form_submit', Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 591)
Drupal\Core\Form\FormBuilder->processForm('user_pass_reset', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm('Drupal\user\Form\UserPasswordResetForm', Object) (Line: 60)
Drupal\prlp\Controller\PrlpController->prlpResetPassLogin(Object, '2021', '1595421632', '3ua2AHeXDDZADL0qBP0MaWM9G2rAOTAQcCk6h4hBFoI')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #18
bwoods commentedI used the patch from @amarlata and removed the line referring to dsu_security_validate. This seems to solve the issue. Here is my overall setup in composer:
"drupal/password_policy": "3.x-dev"
"drupal/prlp": "1.x-dev"
"drupal/prlp": {
"Password reset form validation allows non-matching passwords": "https://www.drupal.org/files/issues/2020-08-25/prlp-form_validation-3143..."
},
"drupal/password_policy": {
"Password policies not apply to 'Forgot password' form": "https://www.drupal.org/files/issues/2020-09-22/3078741-password_policy-p...",
"Password policy and Password Reset Landing Page": "https://www.drupal.org/files/issues/2020-07-20/password_policy-prlp-2943..."
}
Comment #19
sorina.hriban commentedFound an issue. If using forgot password form, the password reset field remains 1 because of the condition:
$uid && ($current_pass || $form_state->get('user_pass_reset')) && $new_passWhen resetting password there is not current pass field, nor user_pass_reset.
Comment #20
v.dovhaliuk commentedFixed problem, when Ajax callback does not apply to the password field after applying patch #18.
There is still a problem with the Ajax form on the "password reset landing page". Problem in \ Drupal \ user \ Controller \ UserController :: getResetPassForm
$ session-> remove ('pass_reset_timeout');
$ session-> remove ('pass_reset_hash');
When Ajax is running, got error 403 Forbidden.
Comment #21
v.dovhaliuk commentedComment #22
v.dovhaliuk commentedComment #23
v.dovhaliuk commentedPatch updated.
Comment #24
vacho commentedThis patch can apply.
Comment #25
vacho commentedFixed
trailing whitespaceissueComment #26
andypostwhy the line commented out?
why you're picking raw parameter? it should be converted already, otherwise it needs comment why you need to load entity
it could use #access => $show_password_policy instead of condition
if empty() should be enough
I bet password reset is not shown for authorized user
Not clear why you're loading the entity again
useless change
weird code reuse
Comment #27
vacho commentedThanks, @andypost for the corrections.
1. Fixed
2. Fixed
3. We can use if because there are 4 form elements that we write in this case.
4. Fixed
5. Password reset is for one user because no user can't reset one password.
6. Reload entity again due to is into ajax method.
7. Fixed
8. Fixed
Comment #28
vacho commentedComment #29
jpatel657 commentedComment #30
jpatel657 commentedThis has been fixed. Please review.
Comment #31
jpatel657 commentedabove comment is not working on registration page
Url: https://www.drupal.org/project/password_policy/issues/3078741#comment-14...
Use this page
Comment #32
vacho commentedqjpatel657 needs to explain why you alter the patch #27 also your last patch only commented on some code lines, if this line is not required should be removed.
Comment #33
Sbonder commentedComment #34
vacho commentedPatch updated an applicable to last version of the module.
Comment #35
sorlov commentedrerolled patch #34 to latest 8.x-3.x version
Comment #36
narres commentedPatch #35 isn't working for me using 8.x.-3.1 with "Could not apply patch!".
With 3.x-de@dev (dev-3.x 103a2c2) I'm getting the "Error: Class 'AccessDeniedHttpException' not found in ... password_policy.module on line 74".
Comment #37
sorlov commentedComment #38
ilya.no commentedI've fixed above error by removing throwing access denied exception, since it's not quite right place for this.
With my update server side validation for the form works, but ajax doesn't work on form and table with constrains stays the same. Need to dig, whether it's my local problem or invalid code, so, please, review, if there is anything wrong with it.
Comment #39
vacho commentedCode and solution work on my side.
Comment #40
vacho commentedComment #41
sfuchsbe commentedUnfortunately, I have to reopen the task. The first test case I checked was failing.
Preconditions:
Expected behavior:
Current behavior:
Because I urgently require this fix I will try to contribute an update until end of this week. In case anyone wants to pick it up - feel free. I won't complain ;)
As this was only the first test, I'm going to test additional use cases as well and in case of any findings will include fixes into my contribution.
Comment #42
sfuchsbe commentedSo, I did some additional testing and found other issues:
I tried to fix all the issues I mentioned above - including the first one related to the roles not being properly respected.
Nevertheless, I think there is additional room for improvements before accepting this fix.
I would highly appreciate if anybody could test my patch as well and provide feedback. This is now open for so many months. Let's bring this to an end!
Comment #43
ciprian.jitaru commentedAdded some fixes.
Comment #44
ciprian.jitaru commentedComment #45
ciprian.jitaru commentedFixed some issues.
Comment #46
ciprian.jitaru commentedComment #47
ciprian.jitaru commentedComment #48
ciprian.jitaru commentedComment #49
ciprian.jitaru commentedComment #50
john franklin commentedThanks for the patch, @sfuchsbe! Your patch in #42 is the first one that actually works for us.
One thing we noticed in our testing. The function
_password_policy_user_pass_reset_form_validate()doesn't seem to be needed, and causes duplicate entries in thepassword_policy_historytable.Comment #51
alexrayu commentedThank you @sfuchsbe,
I have tested and cleaned up your patch, re-rolling here.
Some notes:
1. _password_policy_user_pass_reset_form_validate() is required, and should not be removed (see #50).
2. The duplicated history records in my case come form the double user update hook call, one from password_policy hook and from the "prlp" module. (yes, there is such module, and it's a different module https://www.drupal.org/project/prlp). But it's nothing that we probably can/should fix here - these are two separate modules.
Please review the updated patch.
Comment #52
alexrayu commentedComment #54
the_g_bomb commentedPassword duplicates could be related to another issue that may have been fixed in this issue:
https://www.drupal.org/project/password_policy/issues/3269065
the duplicates can be removed using the update in the follow-up issue:
https://www.drupal.org/project/password_policy/issues/3266140
FYI, there is also an open issue for getting PRLP support added:
https://www.drupal.org/project/password_policy/issues/2362023
Would it be worth reattempting the fix with those patches applied?
Comment #55
john franklin commentedThe patch in #3269065: Data too long for column 'field_last_password_reset_value': incorrect datetime format does not fix the duplicate password history issue, at least not when PRLP is installed.
The patch in #2362023: Support for Password Reset Landing Page (PRLP) conflicted with this one, because both define
password_policy_form_user_pass_reset_alter(). As we already have an older version of the patch here working, we decided to continue using the patches here.We added a separate (internal) patch to Password History that checks if we've already written an item in the password history table for the current UID and the current request timestamp, and skip if one already exists. If/when a new version of this module is released, we'll adopt whichever solution is chosen.
A fix to handle duplicate history entries is supposed to be in #2867320: Password Policy History module wrong behaviour, and that's the best place for it. Debouncing the history update is the responsibility of the Password History module.
Comment #56
wadator commentedrerolled patch #51 to 8.x-3.1 version
Comment #57
wadator commentedComment #58
sophiavs commentedHi, i'll try to work on this
Comment #59
sophiavs commentedI couldn't reproduce the error in the dev version.
The email to reset the password came with [user:one-time-login-url] link, in that way i can only log in and in the edit page the validations work as it was supposed to work. If there is another link that i should put in the email to try to reproduce this error please comment here.
Comment #60
rohan-sinha commentedthis Patch will enable the password policy validation on reset password page.
Add this patch in Composer.json under Drupal/password_policy .
Comment #61
andypostQueued testing of last patch from #56 https://www.drupal.org/pift-ci-job/2612318
Still need tests
Comment #62
joe_carvajalJust to push this up, the patch at #56 looks nice but it does not apply with new 4.0.0 version.
I confirm that the issues persist at 4.0.0.
Comment #63
wadator commentedAdded a new patch for 4.0 version.
Comment #64
kristen polStill needs tests. No more rerolls or updates until there are tests please, but obviously reroll if you add tests and it needs a reroll ;)
Comment #65
mably commentedNot directly related to this issue, but I started implementing my compatibility fix for the prlp module in a new contrib module: https://www.drupal.org/project/password_policy_extras
Comment #68
benstallings commentedComment #69
hchonovI've opened a follow-up for prlp's password_policy sub-module - #3619057: Password policies not apply to "Forgot password" form