From 124fa58b109d291747ea73f62342cf74ae9065ae Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 11 Dec 2006 16:10:12 +0000 Subject: [PATCH] added a xul stash loading method. forcing authtoken to come from xul stash when isXUL so that latest authtoken is used git-svn-id: svn://svn.open-ils.org/ILS/trunk@6673 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/RemoteRequest.js | 26 ++++++++++++++++++++------ Open-ILS/web/opac/common/js/opac_utils.js | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/opac/common/js/RemoteRequest.js b/Open-ILS/web/opac/common/js/RemoteRequest.js index cd888761dc..e5317868f3 100644 --- a/Open-ILS/web/opac/common/js/RemoteRequest.js +++ b/Open-ILS/web/opac/common/js/RemoteRequest.js @@ -218,8 +218,6 @@ RemoteRequest.prototype.send = function(blocking) { if(this.cancelled) return; - - /* determine the xmlhttp server dynamically */ var url = location.protocol + "//" + location.host + "/" + XML_HTTP_GATEWAY; @@ -237,8 +235,6 @@ RemoteRequest.prototype.send = function(blocking) { var data = null; if( this.type == 'GET' ) url += "?" + this.param_string; - if(isXUL() && this.secure ) dump('SECURE = true\n'); - this.url = url; try { @@ -260,7 +256,7 @@ RemoteRequest.prototype.send = function(blocking) { try { var auth; try { auth = cookieManager.read(COOKIE_SES) } catch(ee) {} - if( !auth && isXUL() ) auth = ses(); + if( isXUL() ) auth = fetchXULStash().session.key; if( auth ) this.xmlhttp.setRequestHeader('X-OILS-Authtoken', auth); @@ -299,7 +295,7 @@ RemoteRequest.prototype.getResultObject = function() { var status = null; this.event(null); - /* DEBUG + /* try { dump(this.url + '?' + this.param_string + '\n' + 'Returned with \n\tstatus = ' + this.xmlhttp.status + @@ -322,6 +318,8 @@ RemoteRequest.prototype.getResultObject = function() { var text = this.xmlhttp.responseText; + //try{if(getDebug()) _debug('response: ' + text + '\n')}catch(e){} + if(text == "" || text == " " || text == null) { try { dump('dbg: Request returned no text!\n'); } catch(E) {} if(isXUL()) @@ -372,3 +370,19 @@ RemoteRequest.prototype.addParam = function(param) { this.param_string += "¶m=" + string; } +function fetchXULStash() { + if( isXUL() ) { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var __OILS = new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS"); + var data_cache = new __OILS( ); + return data_cache.wrappedJSObject.OpenILS.prototype.data; + + } catch(E) { + _debug('Error in OpenILS.data._debug_stash(): ' + js2JSON(E) ); + } + } + return {}; +} + + diff --git a/Open-ILS/web/opac/common/js/opac_utils.js b/Open-ILS/web/opac/common/js/opac_utils.js index 47c9e0cb55..ca49b740b7 100644 --- a/Open-ILS/web/opac/common/js/opac_utils.js +++ b/Open-ILS/web/opac/common/js/opac_utils.js @@ -449,6 +449,11 @@ function buildSearchLink(type, string, linknode, trunc) { linknode.setAttribute("href", buildOPACLink(args)); } +function setSessionCookie(ses) { + cookieManager.write(COOKIE_SES, ses, -1); +} + + /* ----------------------------------------------------------------------- */ /* user session handling */ @@ -459,7 +464,11 @@ function buildSearchLink(type, string, linknode, trunc) { if ses != G.user.session, we also force a grab */ function grabUser(ses, force) { - if(!ses && isXUL()) ses = xulG['authtoken']; + if(!ses && isXUL()) { + stash = fetchXULStash(); + ses = stash.session.key + _debug("stash auth token = " + ses); + } if(!ses) { ses = cookieManager.read(COOKIE_SES); @@ -491,7 +500,7 @@ function grabUser(ses, force) { G.user = user; G.user.fleshed = false; G.user.session = ses; - cookieManager.write(COOKIE_SES, ses, -1); + setSessionCookie(ses); grabUserPrefs(); if(G.user.prefs['opac.hits_per_page']) @@ -541,7 +550,7 @@ function grabFleshedUser() { G.user.session = ses; G.user.fleshed = true; - cookieManager.write(COOKIE_SES, ses, '+1y'); /* update the cookie */ + setSessionCookie(ses); return G.user; } -- 2.11.0