Skip to content

Instantly share code, notes, and snippets.

@ralfting
Created August 28, 2015 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralfting/f354fe4ac8be2e98cffa to your computer and use it in GitHub Desktop.
Save ralfting/f354fe4ac8be2e98cffa to your computer and use it in GitHub Desktop.
(function() {
'use_strict';
angular.module('AllPetApp.Users.Services')
.factory('AuthReponseInterceptor', AuthReponseInterceptor);
AuthReponseInterceptor.$inject = ['$q','$location', '$injector'];
function AuthReponseInterceptor($q, $location, $injector){
return {
response: function(response){
console.log(response);
if (response.status === 401) {
console.log("Response 401");
}
return response || $q.when(response);
},
responseError: function(rejection) {
if (rejection.status === 401) {
console.log("Response Error 401",rejection);
$location.path('/login').search('returnTo', $location.path());
}
return $q.reject(rejection);
}
}
}
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment