Bugzilla – Attachment 181695 Details for
Bug 36586
Self-checkouts will get CSRF errors if left inactive for 8 hours
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36586: Add sc-timer to sco
Bug-36586-Add-sc-timer-to-sco.patch (text/plain), 6.67 KB, created by
David Nind
on 2025-04-30 04:09:38 UTC
(
hide
)
Description:
Bug 36586: Add sc-timer to sco
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-04-30 04:09:38 UTC
Size:
6.67 KB
patch
obsolete
>From 54bb21b1f36cbf47d8055b475ba5107c0b8d8419 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 29 Apr 2025 11:19:58 +0000 >Subject: [PATCH] Bug 36586: Add sc-timer to sco > >This patch implements the timer form the last patch on the sco > >To test: >1 - Set SelfCheckTimout to 5 or something low for testing >2 - Go to the self checkout module >3 - Either sign in or confirm you have AutoSelfCheck user setup >4 - Observe the page reloads every 5 seocnds (or as you set above) >5 - Sign in as a patron >6 - Confirm on idle you are logged out to home page >7 - Sign off! > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../bootstrap/en/modules/sco/sco-main.tt | 32 ++++++++++++------- > opac/sco/sco-main.pl | 7 ---- > 2 files changed, 21 insertions(+), 18 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt >index d2d87448b2..84c20c616b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt >@@ -55,6 +55,7 @@ > [% END %] > [% Asset.js('js/Gettext.js') | $raw %] > [% Asset.js('js/i18n.js') | $raw %] >+[% Asset.js('js/timeout.js') | $raw %] > </head> > <body id="sco_main" class="sco"> > <div id="wrapper"> >@@ -328,7 +329,7 @@ > <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off" /> > </div> > <div class="col-md-12"> >- <button type="submit" class="btn btn-primary">Log in</button> >+ <button id="sco_patron_login" type="submit" class="btn btn-primary">Log in</button> > </div> > </div> > <!-- /.row --> >@@ -341,7 +342,7 @@ > <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" /> > </div> > <div class="col-md-12"> >- <button type="submit" class="btn btn-primary">Submit</button> >+ <button id="sco_patron_login" type="submit" class="btn btn-primary">Submit</button> > </div> > </div> > <!-- /.row --> >@@ -401,11 +402,23 @@ > history.replaceState(null, document.title, window.location.href); > } > } >- var mainTimeout; >- function sco_init() { >- mainTimeout = setTimeout(function() { >- location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout'; >- }, [% SelfCheckTimeout | html %]); >+ document.addEventListener("DOMContentLoaded",function(){ >+ if ( document.querySelector('#sco_patron_login,#logout_form') ){ >+ login_timeout(); >+ } >+ }); >+ function login_timeout(){ >+ //NOTE: There can only be 1 sco_login_timer at a time >+ if ( ! window.sco_login_timer ){ >+ const idleTimeout = "[% Koha.Preference('SelfCheckTimeout') || 120 | html %]"; >+ const home_href = "/cgi-bin/koha/sco/sco-main.pl?op=logout"; >+ const sco_timer = new sc_timer({ >+ "idle_timeout": idleTimeout, >+ "redirect_url": home_href >+ }); >+ window.sco_login_timer = sco_timer; >+ sco_timer.start_timer(); >+ } > } > function dofocus() { // named function req'd for body onload event by some FF and IE7 security models > // alert("dofocus called"); >@@ -458,7 +471,6 @@ > > $(document).ready(function() { > dofocus(); >- [% IF ( patronid ) %]sco_init();[% END %] > > var dTables = $("#loanTable, #holdst, #finestable"); > dTables.each(function(){ >@@ -490,18 +502,16 @@ > > $("#logout_form").on("click", function(e){ > e.preventDefault(e); >- clearTimeout(mainTimeout); > [% IF Koha.Preference('SelfCheckReceiptPrompt') %] > var confirmStart = Date.now(); > confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) { >- if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) { >+ if ( result && (Date.now() - confirmStart) < [% Koha.Preference('SelfCheckTimeout') | html %] ) { > var win = window.open("/cgi-bin/koha/sco/printslip.pl?print=qslip"); > location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout'; > } else { > location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout'; > } > }) >- sco_init(); > [% ELSE %] > location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout'; > [% END %] >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index 9ecae7c76c..e1cc93d802 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -74,13 +74,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-# Get the self checkout timeout preference, or use 120 seconds as a default >-my $selfchecktimeout = 120000; >-if ( C4::Context->preference('SelfCheckTimeout') ) { >- $selfchecktimeout = C4::Context->preference('SelfCheckTimeout') * 1000; >-} >-$template->param( SelfCheckTimeout => $selfchecktimeout ); >- > # Checks policy laid out by SCOAllowCheckin, defaults to 'on' if preference is undefined > my $allowselfcheckreturns = 1; > if ( defined C4::Context->preference('SCOAllowCheckin') ) { >-- >2.39.5
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 36586
:
175210
|
175239
|
175919
|
181645
|
181646
|
181694
|
181695
|
181874
|
181875
|
182022
|
182023