From 535b488c9985504537aa5b4ff09309f102841b88 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 7 Dec 2005 21:47:04 +0000 Subject: [PATCH] added login session timeout alerts for when the session is about to expire and for when the session has expired git-svn-id: svn://svn.open-ils.org/ILS/trunk@2272 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/config.js | 2 ++ Open-ILS/web/opac/common/js/opac_utils.js | 33 ++++++++++++++++--- Open-ILS/web/opac/locale/en-US/lang.dtd | 2 ++ .../web/opac/skin/default/xml/ilsevents.xml | 4 +++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/opac/common/js/config.js b/Open-ILS/web/opac/common/js/config.js index d4604c0d36..133c5e114d 100644 --- a/Open-ILS/web/opac/common/js/config.js +++ b/Open-ILS/web/opac/common/js/config.js @@ -59,6 +59,8 @@ var STYPE_SUBJECT = "subject"; var STYPE_SERIES = "series"; var STYPE_KEYWORD = "keyword"; +var LOGOUT_WARNING_TIME = 15; + /* container for global variables shared accross pages */ var G = {}; diff --git a/Open-ILS/web/opac/common/js/opac_utils.js b/Open-ILS/web/opac/common/js/opac_utils.js index 994e38e317..8617f25acf 100644 --- a/Open-ILS/web/opac/common/js/opac_utils.js +++ b/Open-ILS/web/opac/common/js/opac_utils.js @@ -250,10 +250,18 @@ function grabUser(ses, force) { return G.user; /* first make sure the session is valid */ - var request = new Request(FETCH_SESSION, ses ); + var request = new Request(FETCH_SESSION, ses, 1 ); request.send(true); var user = request.result(); + //if(checkILSEvent(user)) throw user; /* unable to grab the session */ + + if(checkILSEvent(user)) { + doLogout(); + return false; /* unable to grab the session */ + } + if( !(typeof user == 'object' && user._isfieldmapper) ) { + doLogout(); return false; } @@ -267,6 +275,9 @@ function grabUser(ses, force) { if(G.user.prefs['opac.hits_per_page']) COUNT = parseInt(G.user.prefs['opac.hits_per_page']); + //new AuthTimer(getAuthtime()).run(); + new AuthTimer(20).run(); + return G.user; } @@ -601,16 +612,30 @@ function _timerRun(tname) { _t.count++; } - - function checkILSEvent(obj) { if( obj.ilsevent != null && obj.ilsevent != 0 ) return parseInt(obj.ilsevent); return null; } function alertILSEvent(code) { - /*alert(code);*/ alert( $('ilsevent.' + code).innerHTML ); } +var __authTimer; +function AuthTimer(time) { + this.time = (time - LOGOUT_WARNING_TIME) * 1000; + __authTimer = this; +} + +AuthTimer.prototype.run = function() { + setTimeout('_authTimerAlert()', this.time); +} + +function _authTimerAlert() { + if( confirm( $('auth_session_expiring').innerHTML ) ) + doLogout(); + else grabUser(null, true); +} + + diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index b48a1cae3d..ef28aa9495 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -50,6 +50,8 @@ + + diff --git a/Open-ILS/web/opac/skin/default/xml/ilsevents.xml b/Open-ILS/web/opac/skin/default/xml/ilsevents.xml index 75759b643e..6db5f476f6 100644 --- a/Open-ILS/web/opac/skin/default/xml/ilsevents.xml +++ b/Open-ILS/web/opac/skin/default/xml/ilsevents.xml @@ -2,5 +2,9 @@ &ilsevent.1000; &ilsevent.5000; &ilsperm.CREATE_HOLD; + + + &opac.session_expiring; + &opac.session_expired; -- 2.43.2