From 4842d73b7aeb6745a9678fb69084f852804856d4 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Mon, 29 Jul 2024 16:35:55 +0200 Subject: [PATCH] Bug 37512: Add a function to reset login attempts When using system preference 'FailedLoginAttempts', a patron's account is blocked after X many failed login attempts on the OPAC. This patch adds, like for "Patron's card has expired" message : * a link to reset login attempts to 0 Link is only displayed if libarian has permission to edit patrons. Reset login attempts to 0 feature uses members/setstatus.pl with resetloginattempts=y like reregistration=y for an expired patron To test: 1. Change system preference 'FailedLoginAttempts' to a small number, like 2 2. Go to a patron's account and copy their username (while you're there, change the password and add some fines, too) 3. In the OPAC, try to log in with the username and a wrong password 3 times 4. Go back to the patron's account in the staff interface 5. Note that there is a message : "Patron's account has been locked (due to 3 failed login attempts)" 6. Click on "Reset login attempts", page reloads and you see patron is unlocked --- koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc | 1 + members/setstatus.pl | 3 +++ 2 files changed, 4 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc index 8a3248a..82d1a35 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc @@ -63,6 +63,7 @@ [% IF CAN_user_borrowers_edit_borrowers %] Change password + or Reset login attempts [% END %] diff --git a/members/setstatus.pl b/members/setstatus.pl index 83ef159..faf9bf9 100755 --- a/members/setstatus.pl +++ b/members/setstatus.pl @@ -40,6 +40,7 @@ my $destination = $input->param("destination") || ''; my $borrowernumber=$input->param('borrowernumber'); my $status = $input->param('status'); my $reregistration = $input->param('reregistration') || ''; +my $resetloginattempts = $input->param('resetloginattempts') || ''; my $dbh = C4::Context->dbh; my $dateexpiry; @@ -54,6 +55,8 @@ if ( $logged_in_user->can_see_patron_infos($patron) ) { if ( $reregistration eq 'y' ) { # re-reregistration function to automatic calcul of date expiry $dateexpiry = $patron->renew_account; + } elsif ( $resetloginattempts eq 'y' ) { + $patron->login_attempts(0)->store; } else { my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?"); $sth->execute( $status, $borrowernumber ); -- 2.43.0