aboutsummaryrefslogtreecommitdiffstats
path: root/ccsdk-app-overlay/src/main/webapp/app/ccsdk/home/http-interceptor.js
blob: 0f5410d81b0bd5771bf9d9394788f4032dd1ece3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
appDS2.factory('httpInterceptor', function ($q, $rootScope, $location) {
        return {
            'request': function (config) {
                return config;
            },
        	/*
            'requestError': function (rejection) {
            },
            */
            'response': function (response) {
                if (response.data == null) {
                	var loc = location.pathname;
                	console.log("location path name: " + loc);
                	var loc1 = loc.replace("/", "");
                	var loc2 = loc1.replace("/ecd", "/login.htm");
                	console.log("location url: " + loc2);
                    alert("Your session has expired. Please log in again...");
                    location.replace("/"+loc2);
                }
                return response;
            },
            // optional method
            'responseError': function (rejection) {
            }
        };
    })
    .config(function($httpProvider) {
		  $httpProvider.interceptors.push('httpInterceptor');
	});