From ca156641bafa6133f6f48044bd44291a12d7d1df Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 29 Aug 2018 10:45:17 -0400 Subject: [PATCH] LP#1775466 Migrate auth cookies to / for sharing Signed-off-by: Bill Erickson --- Open-ILS/web/js/ui/default/staff/services/auth.js | 4 ++++ Open-ILS/web/js/ui/default/staff/services/hatch.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Open-ILS/web/js/ui/default/staff/services/auth.js b/Open-ILS/web/js/ui/default/staff/services/auth.js index 9048a34b78..cf3b78a48d 100644 --- a/Open-ILS/web/js/ui/default/staff/services/auth.js +++ b/Open-ILS/web/js/ui/default/staff/services/auth.js @@ -63,6 +63,10 @@ function($q , $timeout , $rootScope , $window , $location , egNet , egHatch) { * authtoken is found, otherwise rejected */ service.testAuthToken = function() { var deferred = $q.defer(); + + // Move legacy cookies from /eg/staff to / before fetching the token. + egHatch.migrateAuthCookies(); + var token = service.token(); if (token) { diff --git a/Open-ILS/web/js/ui/default/staff/services/hatch.js b/Open-ILS/web/js/ui/default/staff/services/hatch.js index fb0ad682db..31ce360716 100644 --- a/Open-ILS/web/js/ui/default/staff/services/hatch.js +++ b/Open-ILS/web/js/ui/default/staff/services/hatch.js @@ -352,6 +352,24 @@ angular.module('egCoreMod') } } + // Force auth cookies to live under path "/" instead of "/eg/staff" + // so they may be shared with the Angular app. + // There's no way to tell under what path a cookie is stored in + // the browser, all we can do is migrate it regardless. + service.migrateAuthCookies = function() { + [ 'eg.auth.token', + 'eg.auth.time', + 'eg.auth.token.oc', + 'eg.auth.time.oc' + ].forEach(function(key) { + var val = service.getLoginSessionItem(key); + if (val) { + $cookies.remove(key, {path: '/eg/staff/'}); + service.setLoginSessionItem(key, val); + } + }); + } + service.getLoginSessionItem = function(key) { var val = $cookies.get(key); if (val == null) return; -- 2.11.0