app.factory('myHttpResponseInterceptor', ['$q', '$location', function($q, $location) {
return function(promise) {
var success = function(response) {
if (response.status === 302) {
alert("success " + response.status);
$location.path('/login.html');
return response;
} else {
alert("success " + response.status);
return response;
}
};
var error = function(response) {
if (response.status == 401) {
if (response.status === 302) {
alert("error " + response.status);
$location.path('/public/login.html');
return $q.reject(response);
} else {
alert("error " + response.status);
return $q.reject(response);
}
}
return $q.reject(response);
};
return promise.then(success, error);
};
}]);
//Http Intercpetor to check auth failures for xhr requests
app.config(['$httpProvider', function($httpProvider) {
$httpProvider.interceptors.push('myHttpResponseInterceptor');
}]);
$window.location.href ="URL";
Thanks & Regards
Gaurav Ashara
Hi Gaurav
if (response.status == 401) {
if (response.status === 302) {
Will never reach the 302 status. Well, not until 401 and 302 will be equal to JS ;)
I’m not sure if that’s your problem, but that’s what my eye did catch on a quick glimpse
Regards
Sander
Hi Sander,