$httpProvider interceptor
.factory('auth403', ['$rootScope', '$q', '$location', function auth403($rootScope, $q, $location) {
return {
request: function (config) {
console.log(config);
var start = new Date();
return config;
},
response: function (result) {
return result;
},
responseError: function (rejection) {
console.warn('Failed with http', (rejection.message || rejection.status), 'status');
if (rejection.status == 403) {
console.warn('Forbidden, need login to auth');
$location.path('/login');
}
return $q.reject(rejection);
}
};
}])