Bugzilla – Attachment 188666 Details for
Bug 37512
Add a function to reset login attempts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37512: Add a function to reset login attempts
Bug-37512-Add-a-function-to-reset-login-attempts.patch (text/plain), 8.39 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-10-30 16:00:24 UTC
(
hide
)
Description:
Bug 37512: Add a function to reset login attempts
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-10-30 16:00:24 UTC
Size:
8.39 KB
patch
obsolete
>From 6cca171d53147b487cecc82bce2e192bc1545706 Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Wed, 15 Oct 2025 11:05:45 +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. Apply BZ25947 >2. Change system preference 'FailedLoginAttempts' to a small number, like 2 >3. Go to a patron's account and copy their username (while you're there, change the password and add some fines, too) >4. In the OPAC, try to log in with the username and a wrong password 3 times (you might want to use private browsing) >5. Go back to the patron's account details in the staff interface >6. Note that there is a message : "Patron's account has been locked (due to 3 failed login attempts)" >7. Click on the button to reset the login attempts. >8. There is a modal, click on confirm >9. Notice you have been redirected to the account details page. >10. Notice there is no message anymore, notice you can log in again. >11. Repeat 4-9 using the checkout page, notice you are redirected to > the checkout page >--- > circ/circulation.pl | 4 +++- > .../prog/en/includes/patron_messages.inc | 23 +++++++++++++++++++ > .../prog/en/modules/circ/circulation.tt | 2 ++ > .../intranet-tmpl/prog/en/modules/pos/pay.tt | 1 - > members/setstatus.pl | 15 ++++++++++++ > 5 files changed, 43 insertions(+), 2 deletions(-) > >diff --git a/circ/circulation.pl b/circ/circulation.pl >index dddd2a1f5f9..c2f10554797 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -776,7 +776,8 @@ if ( $restoreduedatespec || $stickyduedate ) { > $template->param( > borrowernumber => $borrowernumber, > branch => $branch, >- was_renewed => scalar $query->param('was_renewed') ? 1 : 0, >+ was_renewed => scalar $query->param('was_renewed') ? 1 : 0, >+ was_resetted => scalar $query->param('was_resetted') ? 1 : 0, > barcodes => $barcodes, > stickyduedate => $stickyduedate, > duedatespec => $duedatespec, >@@ -814,6 +815,7 @@ $template->param( > override_high_holds => $override_high_holds, > nopermission => scalar $query->param('nopermission'), > noguarantor => scalar $query->param('noguarantor'), >+ noresetnoguarantor => scalar $query->param('noresetnoguarantor'), > autoswitched => $autoswitched, > logged_in_user => $logged_in_user, > ); >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 25e05462e93..f92906fb430 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc >@@ -67,6 +67,7 @@ > <span> > <a href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | uri %]">Change password</a> > <span data-bs-toggle="tooltip" title="Resetting password will remove lock on account" data-bs-placement="right" class="fa fa-info-circle"> </span> >+ or <a href="" class="reset-login" data-bs-toggle="modal" data-bs-target="#resetAttemptsModal"> Reset login attempts </a> > </span> > [% END %] > </li> >@@ -435,3 +436,25 @@ > </div> > [% END %] > [% END # /IF patron_messages %] >+ >+<div style="font-style:normal;" class="modal notesModal" id="resetAttemptsModal" tabindex="-1" role="dialog" aria-labelledby="resetAttemptsModalLabel"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h1 class="modal-title" id="resetAttemptsLabel">Confirm reset</h1> >+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> >+ </div> >+ <form id="cancel_modal_form" method="post" action="/cgi-bin/koha/members/setstatus.pl"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <input type="hidden" name="op" value="cud-reset_login_attempts" /> >+ <input type="hidden" name="destination" value="[% moremember ? 'member' : 'circ' | html %]" /> >+ <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | uri %]" /> >+ <div class="modal-body"> This will allow the user to try again and login </div> >+ <div class="modal-footer"> >+ <button id="resetAttemptsModalConfirmBtn" type="submit" class="btn btn-primary">Confirm</button> >+ <button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button> >+ </div> >+ </form> >+ </div> >+ </div> >+</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 92e438c86e2..66444e4f6f2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -127,6 +127,8 @@ > > [% IF ( noguarantor ) %] > <div class="alert alert-warning">This patron could not be renewed: they need a guarantor.</div> >+ [% ELSIF ( noresetnoguarantor ) %] >+ <div class="alert alert-warning">No operation can be performed on this patron while no guarantor has been defined</div> > [% END %] > > [% IF is_anonymous %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt >index ee7251f9c6f..5eb0ebaa4d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt >@@ -351,7 +351,6 @@ > } > }, { > "targets": [-5], >- "className": "editable", > }, { > "targets": [-4], > "className": "editable_int", >diff --git a/members/setstatus.pl b/members/setstatus.pl >index 7db0e4f5903..4574ac36547 100755 >--- a/members/setstatus.pl >+++ b/members/setstatus.pl >@@ -39,6 +39,7 @@ my $destination = $input->param("destination") || ''; > my $borrowernumber = $input->param('borrowernumber'); > my $status = $input->param('status'); > my $reregistration = $input->param('reregistration') || ''; >+my $op = $input->param('op'); > > my $dbh = C4::Context->dbh; > my $dateexpiry; >@@ -47,6 +48,7 @@ my $logged_in_user = Koha::Patrons->find( { userid => $loggedinuserid } ); > my $patron = Koha::Patrons->find($borrowernumber); > > my $cannot_renew = '0'; >+my $cannot_reset = '0'; > > # Ideally we should display a warning on the interface if the logged in user is > # not allowed to modify this patron. >@@ -64,6 +66,17 @@ if ( $logged_in_user->can_see_patron_infos($patron) ) { > $_->rethrow(); > } > } >+ } elsif ( $op == "cud-reset_login_attempts" ) { >+ try { >+ $patron->login_attempts(0)->store; >+ $dateexpiry = $patron->renew_account; >+ } catch { >+ if ( ref($_) eq 'Koha::Exceptions::Patron::Relationship::NoGuarantor' ) { >+ $cannot_reset = '1'; >+ } else { >+ $_->rethrow(); >+ } >+ } > } else { > my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?"); > $sth->execute( $status, $borrowernumber ); >@@ -74,6 +87,8 @@ if ( $logged_in_user->can_see_patron_infos($patron) ) { > if ( $destination eq "circ" ) { > if ($cannot_renew) { > print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber&noguarantor=1"); >+ } elsif ($cannot_reset) { >+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber&noresetnoguarantor=1"); > } elsif ($dateexpiry) { > print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber&was_renewed=1"); > } else { >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37512
:
169845
|
169846
|
169854
|
169865
|
176958
|
177061
|
179433
|
179470
|
179471
|
179829
|
179830
|
184730
|
184731
| 188666