From: erickson Date: Tue, 16 Nov 2010 23:33:27 +0000 (+0000) Subject: in the staff client, use the user object in the XUL stash instead of grabbing the... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f557b9758e0f4f096b9403d6895f0a67bcb43d09;p=evergreen%2Fbjwebb.git in the staff client, use the user object in the XUL stash instead of grabbing the user object on each page load for embedded staff web UIs (/eg/). This is one less pre-onload XHR and another step in the avoidance of the cursed WSOD. Added support for launching the xul login dialog after a timed out session event is returned. git-svn-id: svn://svn.open-ils.org/ILS/trunk@18763 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index f670b696f..729fa165f 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -143,7 +143,22 @@ if(!dojo._hasResource["openils.Util"]) { if(e = openils.Event.parse(testval)) { if(eventOk) return e; console.log(e.toString()); - if(openils.Util.alertEvent) + + // session timed out. Stop propagation of requests queued by Util.onload + // and launch the XUL login dialog if possible + var retryLogin = false; + if(e.textcode == 'NO_SESSION') { + openils.User.authtoken = null; + if(openils.XUL.isXUL()) { + retryLogin = true; + openils.XUL.getNewSession( function() { location.href = location.href } ); + } else { + // TODO: make the oilsLoginDialog templated via dojo so it can be + // used as a standalone widget + } + } + + if(openils.Util.alertEvent && !retryLogin) alert(e); return null; } diff --git a/Open-ILS/web/js/ui/base.js b/Open-ILS/web/js/ui/base.js index 4a57cd7af..cf924c1e2 100644 --- a/Open-ILS/web/js/ui/base.js +++ b/Open-ILS/web/js/ui/base.js @@ -13,20 +13,26 @@ function oilsSetupUser() { var authtoken = cgi.param('ses') || dojo.cookie('ses'); var workstation = cgi.param('ws') || dojo.cookie('ws'); var user; + var ses_user; openils.User.user = null; openils.User.authtoken = null; openils.User.workstation = null; - if(!authtoken && openils.XUL.isXUL()) { + if(openils.XUL.isXUL()) { stash = openils.XUL.getStash(); authtoken = stash.session.key + ses_user = stash.list.au[0]; } if(authtoken) { user = new openils.User(); delete user.sessionCache[authtoken]; user.authtoken = authtoken; + if(ses_user) { + user.user = ses_user; + user.sessionCache[authtoken] = ses_user; + } user.user = user.getBySession(); }