in the staff client, use the user object in the XUL stash instead of grabbing the...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 16 Nov 2010 23:33:27 +0000 (23:33 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 16 Nov 2010 23:33:27 +0000 (23:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18763 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/Util.js
Open-ILS/web/js/ui/base.js

index f670b69..729fa16 100644 (file)
@@ -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;
         }
index 4a57cd7..cf924c1 100644 (file)
@@ -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();
     }