Apply password policies to password elements on custom forms

Created on 16 November 2017, over 6 years ago
Updated 7 April 2024, 3 months ago

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

✨ Feature request
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

🇮🇪Ireland paddy.doyle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024