* 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) {
}
}
+ // 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;