From b537bb6faf0903f81ab3cf707540193079806d22 Mon Sep 17 00:00:00 2001 From: vladnicoara Date: Mon, 8 Sep 2014 16:13:32 +0300 Subject: [PATCH] LB-1964 Angularjs session management --- .../scripts/js/manage-feeds/manage-feeds.js | 18 +++++++++---- .../gui-resources/scripts/js/seo-config.js | 25 ++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/plugins/livedesk/gui-resources/scripts/js/manage-feeds/manage-feeds.js b/plugins/livedesk/gui-resources/scripts/js/manage-feeds/manage-feeds.js index 5c04eef24..dd565d11a 100644 --- a/plugins/livedesk/gui-resources/scripts/js/manage-feeds/manage-feeds.js +++ b/plugins/livedesk/gui-resources/scripts/js/manage-feeds/manage-feeds.js @@ -2,19 +2,27 @@ define([ 'jquery', 'angular', config.guiJs('livedesk', 'authorization'), - ],function($, angular, auth){ + 'interceptor' + ],function($, angular, auth, interceptor){ var angularHeaders = $.extend({}, auth, { 'Content-Type': 'text/json' }); var feeds = angular.module('manageFeeds',[]); feeds.config(['$interpolateProvider', function($interpolateProvider) { $interpolateProvider.startSymbol('{{ '); $interpolateProvider.endSymbol(' }}'); }]); + feeds.run(function($http){ + var authObject = { + 'Authorization': localStorage.getItem('superdesk.login.session') + } + var angularHeaders = $.extend({}, authObject, { 'Content-Type': 'text/json' }); + $http.defaults.headers.get = authObject; + $http.defaults.headers.post = angularHeaders; + $http.defaults.headers.put = angularHeaders; + $http.defaults.headers.delete = authObject; + }); feeds.config(function($httpProvider){ delete $httpProvider.defaults.headers.common['X-Requested-With']; - $httpProvider.defaults.headers.get = auth; - $httpProvider.defaults.headers.post = angularHeaders; - $httpProvider.defaults.headers.delete = auth; - $httpProvider.defaults.headers.put = angularHeaders; + $httpProvider.interceptors.push(interceptor); }); return feeds; }); \ No newline at end of file diff --git a/plugins/livedesk/gui-resources/scripts/js/seo-config.js b/plugins/livedesk/gui-resources/scripts/js/seo-config.js index c1938d110..8c96f45bf 100644 --- a/plugins/livedesk/gui-resources/scripts/js/seo-config.js +++ b/plugins/livedesk/gui-resources/scripts/js/seo-config.js @@ -2,8 +2,9 @@ define([ 'jquery', 'angular', 'gizmo/superdesk', - config.guiJs('livedesk', 'authorization') - ], function($, angular, Gizmo, auth){ + config.guiJs('livedesk', 'authorization'), + 'interceptor' + ], function($, angular, Gizmo, auth, interceptor){ function getGizmoUrl(path) { var url = new Gizmo.Url(path); return url.get(); @@ -11,19 +12,25 @@ define([ function relativeToAbsolute(rel) { return window.location.protocol + '//' + window.location.host + rel; } - var angularHeaders = $.extend({}, auth, { 'Content-Type': 'text/json' }); var seoconf = angular.module('seoConf',[]); seoconf.config(['$interpolateProvider', function($interpolateProvider) { $interpolateProvider.startSymbol('{{ '); $interpolateProvider.endSymbol(' }}'); }]); - seoconf.config(function($httpProvider){ + seoconf.run(function($http){ + var authObject = { + 'Authorization': localStorage.getItem('superdesk.login.session') + } + var angularHeaders = $.extend({}, authObject, { 'Content-Type': 'text/json' }); + $http.defaults.headers.get = authObject; + $http.defaults.headers.post = angularHeaders; + $http.defaults.headers.put = angularHeaders; + $http.defaults.headers.delete = authObject; + }); + seoconf.config(['$httpProvider', function($httpProvider){ delete $httpProvider.defaults.headers.common['X-Requested-With']; - $httpProvider.defaults.headers.get = auth; - $httpProvider.defaults.headers.post = angularHeaders; - $httpProvider.defaults.headers.put = angularHeaders; - $httpProvider.defaults.headers.delete = auth; - }); + $httpProvider.interceptors.push(interceptor); + }]); seoconf.factory('seoInterfaceData', ['$http', '$q', function($http, $q){ return {