Bug 33820: Add hints to warn the librarian that they will be logged out if they change their username

This patch adds some JavaScript to the patron entry form which adds a
hint if the logged-in librarian tries to change their own username. It
warns them that they will be logged out.

To test, apply the patch and log into the staff interface.

- Locate and edit your own patron record.
- In the "OPAC/Staff interface login" section, change the value in the
  username field. When focus leaves that form field a hint should
  appear, "You will be logged out if you modify your username."
- Change the username field back to your original username. The hint
  should disappear.
- Confirm that submitting a username change works correctly: You should
  be logged out, and when you log in again your username should be
  updated.

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 8e611b79f1)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-05-24 09:31:05 +02:00 committed by Martin Renvoize
parent 25230f4cf9
commit b2c7a37906
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 10 additions and 0 deletions

View File

@ -1867,6 +1867,16 @@ legend:hover {
$("#categorycode_entry").on("change", function(){
update_category_code(this);
});
[% IF logged_in_user.borrowernumber == borrowernumber %]
$("#userid").on("change", function(){
$(this).parent().find("div.hint").remove();
if ( "[% borrower_data.userid | html %]" != $(this).val() ) {
$(this).parent().append('<div class="hint">%s</div>'.format(_("You will be logged out if you modify your username")));
}
});
[% END %]
});
[% IF quickadd && opadd && !check_member %]