Problem/Motivation
This module always displays a status message informing the user that the password was autogenerated:
Since you did not provide a password, it was generated automatically for this account.

The message makes sense when it is optional but seems confusing if your site is configured to disallow it. You are informing the user of something they don't need to know about and can't control.
Proposed resolution
Don't display this message if 'Admins cannot set a password when creating or editing an account.' is selected.
Remaining tasks
- ✅ Confirm this makes sense?
- ✅ Make the change
- ✅ Update tests
- ✅ Review
- ✅ Commit
- ✅ Port to 2.0.x branch
User interface changes
- Admin is not to be notified they didn't enter a password if they didn't have the option to do so.
API changes
- N/A
Data model changes
- N/A
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork genpass-3480687
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
pameeela commentedComment #3
diwakar07 commentedHi,
I was able to reproduce the above mentioned bug.
I agree that hiding the message will eliminate the chances of confusion, when 'Admins cannot set a password when creating or editing an account.' is selected, as there is no option add a password when this option is selected.
Comment #5
diwakar07 commentedHi,
Made the changes to hide the message, when "Admins cannot set a password when creating or editing an account." is selected.
Please review.
Thanks & regards.
Comment #6
pameeela commentedThanks @diwakar07! Looks like there are tests that need to be updated. I am also not sure if the module maintainers will accept this change.
Comment #7
elc commentedThe OP concept makes sense.
If there's a situation where the message is appearing out of context then it should not show. I didn't think it showed in such situations anyway but the addition of the admin restrictions looks to have added it.
https://git.drupalcode.org/project/genpass/-/blob/2.1.x/genpass.module#L...
Not sure the MR covers all of the situations, although it does only appear to show for admin create user? Keeping with the similar style as the above it would be good where parts of conditions are stored in variables to be compared in the if statement to keep the line length to <80 and keep the code readable. And yes, tests need to be added to specifically test for the changed situation.
Comment #8
elc commentedThis boiled down to "if the admin is given the password field, let them know they didn't enter anything"; perhaps they had wanted to enter a password but they forgot. The password display setting also needed to be respected.
Updated the MR changed the logic, and added tests; Combining the condition meant that the password display setting was ignored, and caused more conditional checks that is needed for the admin - if the admin_mode was set to PASSWORD_ADMIN_HIDE then the messaging fell back to user settings instead which is not desired.
Comment #9
pameeela commentedAwesome, thanks! Just updated the title to reflect that this change is good to make. I will manually test when I get a chance.
Comment #10
pameeela commentedThis change is straightforward and logical, with a passing test, so looks good to me. Thanks for actioning it so quickly!
Edit: I also did manually test it!
Comment #14
elc commentedPorted to previous branch too.
This will actually trigger a release as there are number of commits in both branches that have been sitting around waiting for a reason.
Comment #15
elc commentedFailure of "phpunit (next minor)" does not appear to be temporary so, #3482165: phpunit (next minor) failing