From 3048ed3a281863ca7e1fcce0dda39fba1550e6a4 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 2 Apr 2010 15:15:58 +0000 Subject: [PATCH] added wrapper to new XUL get_new_session call. when embedded ui's lose their session, launch the staff client's login dialog instead of the local web-only dialog git-svn-id: svn://svn.open-ils.org/ILS/trunk@16101 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/XUL.js | 7 +++++++ Open-ILS/web/js/ui/base.js | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/XUL.js b/Open-ILS/web/js/dojo/openils/XUL.js index c93cca2df8..6c26acd5e4 100644 --- a/Open-ILS/web/js/dojo/openils/XUL.js +++ b/Open-ILS/web/js/dojo/openils/XUL.js @@ -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 diff --git a/Open-ILS/web/js/ui/base.js b/Open-ILS/web/js/ui/base.js index cd723bfe23..ba4652b681 100644 --- a/Open-ILS/web/js/ui/base.js +++ b/Open-ILS/web/js/ui/base.js @@ -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'); -- 2.11.0