In the staff interface, on the "Change password" page, it's not possible to update a patron's username without also entering password information. This is contrary to the help text, "Leave the field blank to leave password unchanged." As far as I can tell this bug goes back to at least 21.05.x
It kind of makes sense that it behaves this way because it is on the "Change Password" page and not a page designed for just changing the username. The text at the bottom is just counterintuitive in my opinion.
Should we perhaps change this script so that it just changes the password and doesn't affect the username?
(In reply to David Cook from comment #2) > Should we perhaps change this script so that it just changes the password > and doesn't affect the username? We use the change username functionality; it'd be a shame to lose this.
Created attachment 164506 [details] [review] Bug 33832: Allow updating username without changing password on member-password.pl This patch updates the change password page on the staff interface to allow for changing the patron's username without changing the password. If the new password is an empty string we can skip setting the patron's password and sending the new password to the template.
Created attachment 164507 [details] [review] Bug 33832: Allow updating username without changing password on member-password.pl This patch updates the change password page on the staff interface to allow for changing the patron's username without changing the password. If the new password is an empty string we can skip setting the patron's password and sending the new password to the template. Test plan: 1. From a patron record tool bar click 'Change password' 2. Notice that if you try to change the user's name without also changing the password the page just reloads and nothing happens 3. Apply patch and restart_all 4. From the patron record click 'Change password' again 5. Set the user's new username and password eg. '1234Abc' and click 'Save' 6. Confirm that you can log in to the OPAC with the user 7. Return to the patron record and click 'Change password' again 8. This time change just the 'New username field' and click 'Save' 6. Notice that the username is updated 7. Confirm you can log into the OPAC with the new username and the original password '1234Abcd' 8. Make sure that the change password form still validates passwords for length and matching errors etc
Created attachment 164522 [details] [review] Bug 33832: Allow updating username without changing password on member-password.pl This patch updates the change password page on the staff interface to allow for changing the patron's username without changing the password. If the new password is an empty string we can skip setting the patron's password and sending the new password to the template. Test plan: 1. From a patron record tool bar click 'Change password' 2. Notice that if you try to change the user's name without also changing the password the page just reloads and nothing happens 3. Apply patch and restart_all 4. From the patron record click 'Change password' again 5. Set the user's new username and password eg. '1234Abc' and click 'Save' 6. Confirm that you can log in to the OPAC with the user 7. Return to the patron record and click 'Change password' again 8. This time change just the 'New username field' and click 'Save' 6. Notice that the username is updated 7. Confirm you can log into the OPAC with the new username and the original password '1234Abcd' 8. Make sure that the change password form still validates passwords for length and matching errors etc Signed-off-by: Esther <esther@bywatersolutions.com>
Seeing this: if ( $op eq 'cud-update' && $newpassword.defined and not @errors ) { What is $newpassword.defined ?? Wondering why perl does compile that? Please explain.
(In reply to Marcel de Rooy from comment #7) > Seeing this: > if ( $op eq 'cud-update' && $newpassword.defined and not @errors ) { > > What is $newpassword.defined ?? > Wondering why perl does compile that? > Please explain. It looks like a copy/paste error from the template toolkit where scalar values can have methods. It looks like Perl compiles it because "." is used to concatenate things together. It looks like $newpassword.defined is equivalent to $newpassword . defined $_ "Returns a Boolean value telling whether EXPR has a value other than the undefined value undef. If EXPR is not present, $_ is checked." https://perldoc.perl.org/functions/defined Yikes!
Although I think using "defined" at all in this context is probably wrong anyways.
(In reply to David Cook from comment #8) > It looks like $newpassword.defined is equivalent to $newpassword . defined $_ Ah yes that sounds like it.
(In reply to Marcel de Rooy from comment #10) > (In reply to David Cook from comment #8) > > It looks like $newpassword.defined is equivalent to $newpassword . defined $_ > > Ah yes that sounds like it. Good catch though. When I first looked at it, I couldn't believe what I was seeing. Thought I was looking at some Ruby missing the question mark...
(In reply to David Cook from comment #8) > (In reply to Marcel de Rooy from comment #7) > > Seeing this: > > if ( $op eq 'cud-update' && $newpassword.defined and not @errors ) { > > > > What is $newpassword.defined ?? > > Wondering why perl does compile that? > > Please explain. > > It looks like a copy/paste error from the template toolkit where scalar > values can have methods. I'm new to Perl and mixed up this syntax from template tool kit. I think it should have been written as defined($newpassword) The idea of this patch is that if the user does not fill the form with both 'New password' and 'Confirm new password' then there's no need to check and set the password. I think this patch is close but needs another try.
It looks like the change to the template is not necessary and is causing JS errors in the browser console. Including the password-checking JS doesn't seem to cause a problem whether or not the password is being updated.
Created attachment 164856 [details] [review] Bug 33832: Allow updating username without changing password on member-password.pl This patch updates the change password page on the staff interface to allow for changing the patron's username without changing the password. If the new password is an empty string we can skip setting the patron's password and sending the new password to the template. Test plan: 1. From a patron record tool bar click 'Change password' 2. Notice that if you try to change the user's name without also changing the password the page just reloads and nothing happens 3. Apply patch and restart_all 4. From the patron record click 'Change password' again 5. Set the user's new username and password eg. '1234Abc' and click 'Save' 6. Confirm that you can log in to the OPAC with the user 7. Return to the patron record and click 'Change password' again 8. This time change just the 'New username field' and click 'Save' 6. Notice that the username is updated 7. Confirm you can log into the OPAC with the new username and the original password '1234Abcd' 8. Make sure that the change password form still validates passwords for length and matching errors etc
(In reply to Owen Leonard from comment #13) > It looks like the change to the template is not necessary and is causing JS > errors in the browser console. Including the password-checking JS doesn't > seem to cause a problem whether or not the password is being updated. Thanks for checking, Owen. I removed the change to the template. I also changed the Perl that I had mixed up with template toolkit syntax to check defined($newpassword). The reason we have to check if the new password is defined is because if the user leaves the input blank, the Perl script gets the param as an empty string. If you check the value of the empty string it evaluates to false.
Created attachment 164858 [details] [review] Bug 33832: Allow updating username without changing password on member-password.pl This patch updates the change password page on the staff interface to allow for changing the patron's username without changing the password. If the new password is an empty string we can skip setting the patron's password and sending the new password to the template. Test plan: 1. From a patron record tool bar click 'Change password' 2. Notice that if you try to change the user's name without also changing the password the page just reloads and nothing happens 3. Apply patch and restart_all 4. From the patron record click 'Change password' again 5. Set the user's new username and password eg. '1234Abc' and click 'Save' 6. Confirm that you can log in to the OPAC with the user 7. Return to the patron record and click 'Change password' again 8. This time change just the 'New username field' and click 'Save' 6. Notice that the username is updated 7. Confirm you can log into the OPAC with the new username and the original password '1234Abcd' 8. Make sure that the change password form still validates passwords for length and matching errors etc Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Created attachment 164987 [details] [review] Bug 33832: Allow updating username without changing password on member-password.pl This patch updates the change password page on the staff interface to allow for changing the patron's username without changing the password. If the new password is an empty string we can skip setting the patron's password and sending the new password to the template. Test plan: 1. From a patron record tool bar click 'Change password' 2. Notice that if you try to change the user's name without also changing the password the page just reloads and nothing happens 3. Apply patch and restart_all 4. From the patron record click 'Change password' again 5. Set the user's new username and password eg. '1234Abc' and click 'Save' 6. Confirm that you can log in to the OPAC with the user 7. Return to the patron record and click 'Change password' again 8. This time change just the 'New username field' and click 'Save' 6. Notice that the username is updated 7. Confirm you can log into the OPAC with the new username and the original password '1234Abcd' 8. Make sure that the change password form still validates passwords for length and matching errors etc Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Clear code, QA scripts happy, resolves the issue.. Passing QA, thanks Brendan.
Pushed for 24.05! Well done everyone, thank you!
Pushed to 23.11.x for 23.11.06
I think we should add an error when login is empty saying one can not remove login here. NB it allows 0 has password but not as login ;)
Backported to 23.05.x for upcoming 23.05.12