Hi,
Thanks for the great module.
So I wanted to use it on a D8 site with custom forms (including non-account, non-entity forms), and spotted this issue: 2562481
That has the D7 patch, and is tagged 8.x-3.x-dev but it felt wrong to piggy-back a purely D8 patch onto it, so I hope I'm doing the right thing by creating a new issue. If not please let me know.
I'll upload a patch which includes the idea of the 2562481 #23 patch to use hook_form_alter and test for the existence of a password form element.
I've tested the patch on 8.3.x and 8.4.x and it seems to work on both.
I've also included some other fixes for D8:
- rename parameter in password_policy_element_info_alter() to better match the core modules
- pass in the $form to _password_policy_show_policy() to catch a specific use case: when the form is 'user_register_form' and 'verify_mail' is set in the config
- extra parameters to password_policy_check_constraints_password_confirm_process() to be able to pass the $form to _password_policy_show_policy()
- extra check in _password_policy_constraints_validate() to test if there is a 'roles' element in the form before reading the values
- extra check in _password_policy_user_profile_form_submit() to test if it's an EntityForm before trying to save user data
Paddy
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 2924009_20.patch | 6.85 KB | vsujeetkumar |
| #19 | 2924009_19.patch | 6.84 KB | vsujeetkumar |
| #12 | interdiff-2924009-9-12.txt | 718 bytes | froboy |
| #12 | 2924009-apply-to-custom-forms-12.patch | 7.04 KB | froboy |
| #9 | 2924009-apply-to-custom-forms-9.patch | 7.69 KB | froboy |
Issue fork password_policy-2924009
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
paddy.doyle commentedComment #3
paddy.doyle commentedFix coding standard fails.
Comment #4
paddy.doyle commentedInterdiff
Comment #5
dakku commentedD8 ++
Comment #6
paddy.doyle commentedRe-patched against latest dev version.
Simplified the patch with respect to changes to hook_form_alter(), so probably no point in an interdiff.
Comment #7
froboyRe-patching against latest dev. Nothing changed other than some indexes.
Comment #8
froboyI'm having trouble with this patch but need to pivot to something else. It looks like the
array_combinearound like 230 infunction _password_policy_constraints_validateisn't producing the proper results.I think that line should be replaced with:
I'm also seeing "The password does not satisfy the password policies." on every step of my custom, multi-step form, so it's possible this still needs to be adapted to account for multi-step forms.
Comment #9
froboyPatch with interdiff described above.
Comment #10
aohrvetpv commentedHello, thanks for the patches, all. I took a quick look and, unless I'm mistaken, the latest (#9) has several changes unrelated to this issue. For instance, type hinting is added to unrelated functions. Could the unrelated changes please be removed so we can review the code relevant to this issue?
Comment #11
froboy@AohRveTPV thanks for taking a look. I did my best to recreate the patch from #6 as closely as possible with the latest dev, but I'm happy to remove things if you might clarify what seems extraneous?
The type hinting I see is in
function _password_policy_constraints_tableandfunction _password_policy_check_constraintsand I agree that seems like it could be extraneous (although open to argument from @paddy.doyle if they're still listening). Are there other changes you'd like to see removed?Thanks for clarifying.
Comment #12
froboyInitial requested changes.
Comment #13
3ssom commentedHello froboy,
I tried this against pretty much all d8 versions but it won't apply .. I also tried the previous patches but not luck either.
Regards
Essam
Comment #14
ant1@3ssom: This patch seems to apply on '8.x-3.0-alpha5' for me.
But from there, I am stuck as well.
How do I trigger a password policy for a custom form (or in my case: Password Reset Landing Page)?
Thanks in advance.
Comment #15
3ssom commentedHello
I just installed new Drupal install with Version: 8.x-3.0-alpha5 of this module to test it applies but still the same:
I'm not sure how did you apply it!
So me not getting this to work which I by the way need in my custom registrations form makes difficult to answer your question because I don't know how it should work! it might get attached to any ['account']['pass'] if it's == 'password_confirm'.
If you read the code that what you will see but unfortunately I can't see that .. if you could please make sure how did you apply the patch so we can help each other on this! I'm stuck also here.
Regards
Comment #16
ant1My apologies, I made a mistake.
It should work on 8.x-3.x-dev using cweagans/composer-patches (well, it says it applied succesfully).
Comment #17
ant1The patch doesn't apply anymore (probably because of #2971079: Can't edit user profile because password policy validates even when password unchanged).
Comment #18
vsujeetkumar commentedComment #19
vsujeetkumar commentedRe-roll patch created, Please review.
Comment #20
vsujeetkumar commentedPlease ignore previous patch(#19).
Comment #22
ant1The patch does apply, but I see no changes.
Comment #24
kristen polThanks to everyone for your work on this issue.
As the 8.x is no longer supported, I'm postponing this issue for now and need feedback as to whether or not this issue is relevant to 4.0.x.
If it is, please reopen and change the version, make sure the issue summary is clear and complete, including concrete steps to reproduce, and reroll the patch. If it's not, please close.
If there is no response to this in a month addressing the above, it can be closed.
Comment #25
kristen polNote that I just closed #2562481: Apply password policies to account password elements on custom forms as fixed, which is the Drupal 7 version. Refer to that code if needed.