aboutsummaryrefslogtreecommitdiffstats
path: root/app/app.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/app.config.js')
-rw-r--r--app/app.config.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/app/app.config.js b/app/app.config.js
new file mode 100644
index 0000000..952c221
--- /dev/null
+++ b/app/app.config.js
@@ -0,0 +1,65 @@
+(function () {
+ 'use strict';
+
+ angular
+ .module('dcaeApp')
+ .factory('httpRequestInterceptor', function ($injector, $rootScope) {
+ var httpRequestInterceptor = {
+ request: function (config) {
+ // Send the user only for API requests
+ var userId = "";
+ if ($rootScope.baseURL.indexOf('localhost') !== -1) {
+ // if (config.url.indexOf($rootScope.baseURL) !== -1) {
+ config.headers = config.headers || {};
+ userId = 'ym903w';
+ // userId = $injector .get('Sdc.Services.CookieService') .getUserId();
+ var user = {
+ userId: userId
+ };
+ if (user) {
+ config.headers['USER_ID'] = user.userId;
+ }
+ // }
+ } else {
+ config.headers = config.headers || {};
+ var user = {
+ userId: window.userId
+ };
+ userId = window.userId;
+ // var user = { userId: $rootScope.cookieUser }; userId =
+ // $rootScope.cookieUser;
+ if (user) {
+ config.headers['USER_ID'] = user.userId;
+ console.log('Your User is:', user.userId);
+ } else {
+ console.log('Error look on your grunt file you dont have a user set');
+ }
+
+ }
+ $rootScope.userId = userId;
+ return config;
+ }
+ };
+ return httpRequestInterceptor;
+ })
+ .config(config);
+
+ function config($httpProvider) {
+
+ // Ask for cross domain from the sever (need to allow this in server).
+ $httpProvider.defaults.useXDomain = true;
+ delete $httpProvider.defaults.headers.common['X-Requested-With'];
+
+ $httpProvider
+ .interceptors
+ .push('httpRequestInterceptor');
+
+ // HTTP Interceptor definition
+ /*$httpProvider.interceptors.push('httpRequestInterceptor');
+ $httpProvider.interceptors.push('httpResponseInterceptor');
+ $httpProvider.interceptors.push('httpRequestErrorInterceptor');
+ $httpProvider.interceptors.push('httpResponseErrorInterceptor');*/
+
+ }
+
+})();