https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36586

--- Comment #57 from Michael Grgurev <[email protected]> ---
/* Interim fix for use in SCOUserJS */

/* ---- Self checkout page reload on idle to avoid CSRF errors ---- */
/* IF STATEMENT: Limit to cardnumber entry screen, though not strictly
necessary */
if(document.body.id == "sco_main" && !$('body').hasClass('CheckingOut')) {
        let timeoutMinutes = 5;         /* Time, in minutes, to refresh when no
user input. */
        let idleTimer = 0;
        const idleInterval = setInterval(idleUpdate, 1000);
        const idleThreshold = timeoutMinutes * 60;

        function resetTimer() { idleTimer = 0; }
        function idleUpdate() {
                idleTimer++;
                if (idleTimer >= idleThreshold) {
                        location.reload(true);          /* Reload page to
refresh CSRF token */
                        clearInterval(idleInterval);
                }
        }

        /* Check for standard user input events (no reload when interaction is
occuring) */
        for (var e of
["mousemove","keypress","mousedown","touchstart","scroll"]) {
                document.addEventListener(e, resetTimer);
        }
        resetTimer();  
 }

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to