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

  1. ✅ Confirm this makes sense?
  2. ✅ Make the change
  3. ✅ Update tests
  4. ✅ Review
  5. ✅ Commit
  6. ✅ 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

CommentFileSizeAuthor
Screenshot 2024-10-15 at 4.20.26 pm.png13.38 KBpameeela

Issue fork genpass-3480687

Command icon 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

pameeela created an issue. See original summary.

pameeela’s picture

Issue summary: View changes
diwakar07’s picture

Assigned: Unassigned » diwakar07

Hi,
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.

diwakar07’s picture

Assigned: diwakar07 » Unassigned
Status: Active » Needs review

Hi,
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.

pameeela’s picture

Issue summary: View changes
Status: Needs review » Needs work

Thanks @diwakar07! Looks like there are tests that need to be updated. I am also not sure if the module maintainers will accept this change.

elc’s picture

The 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.

elc’s picture

Issue summary: View changes
Status: Needs work » Needs review

This 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.

pameeela’s picture

Title: Consider hiding the status message when admins cannot set a password on account creation » Hide the status message when admins cannot set a password on account creation

Awesome, thanks! Just updated the title to reflect that this change is good to make. I will manually test when I get a chance.

pameeela’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

This 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!

  • elc committed a3c404d5 on 2.1.x authored by diwakar07
    [#3480687] by ELC, pameeela, diwakar07: Only display password generated...

  • elc committed 9007fbb9 on 2.0.x
    [#3480687] by ELC, pameeela, diwakar07: Only display password  generated...
elc’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Ported 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.

elc’s picture

Failure of "phpunit (next minor)" does not appear to be temporary so, #3482165: phpunit (next minor) failing

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.