added wrapper to new XUL get_new_session call. when embedded ui's lose their session...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 2 Apr 2010 15:15:58 +0000 (15:15 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 2 Apr 2010 15:15:58 +0000 (15:15 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16101 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index c93cca2..6c26acd 100644 (file)
@@ -33,6 +33,13 @@ if(!dojo._hasResource["openils.XUL"]) {
         xulG.new_tab(path, tabInfo, options);
     }
 
+    /**
+     * @return bool True if a new session was successfully created, false otherwise.
+     */
+    openils.XUL.getNewSession = function(callback) {
+        return xulG.get_new_session({callback : callback});
+    }
+
     /** 
      * This can be used by privileged Firefox in addition to XUL.
      * To use use in Firefox directly, set signed.applets.codebase_principal_support to true in about:config
index cd723bf..ba4652b 100644 (file)
@@ -6,6 +6,7 @@ dojo.require('openils.User');
 dojo.require('openils.CGI');
 dojo.require('openils.Event');
 dojo.require('openils.Util');
+dojo.require('openils.XUL');
 
 function oilsSetupUser() {
     var cgi = new openils.CGI();
@@ -17,11 +18,17 @@ function oilsSetupUser() {
         dojo.cookie('ses', openils.User.authtoken, {expires:-1, path:'/'}); // remove the cookie
         openils.User.authtoken = null;
         dojo.addOnLoad(function(){
-            oilsLoginDialog.show(); 
-            var func = function(){ oilsDoLogin(); };
-            openils.Util.registerEnterHandler(dojo.byId('oils-login-username'), func);
-            openils.Util.registerEnterHandler(dojo.byId('oils-login-password'), func);
-            dojo.byId('oils-login-workstation').innerHTML = workstation || '';
+            if(openils.XUL.isXUL()) {
+                // let XUL handle the login dialog
+                openils.XUL.getNewSession( function() { location.href = location.href } );
+            } else {
+                // in web-only mode, use the dojo login dialog
+                oilsLoginDialog.show(); 
+                var func = function(){ oilsDoLogin(); };
+                openils.Util.registerEnterHandler(dojo.byId('oils-login-username'), func);
+                openils.Util.registerEnterHandler(dojo.byId('oils-login-password'), func);
+                dojo.byId('oils-login-workstation').innerHTML = workstation || '';
+            }
         });
         return;
     }
@@ -44,7 +51,7 @@ function oilsDoLogin() {
         args.workstation = workstation;
 
     if(user.login(args)) {
-        dojo.cookie('ses', user.authtoken, {path : '/'});
+        dojo.cookie('ses', user.authtoken, {path : oilsBasePath});
         location.href = location.href;
     } else {
         openils.Util.show('oils-login-failed');