Created
August 7, 2013 16:36
-
-
Save mariojunior/6175736 to your computer and use it in GitHub Desktop.
AngularJS Learned Lessons #1: - Getting a Invalid Session State on response and trait it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Intercepting a Invalid Session status using an Interceptor: | |
//Following the sample described in http://docs.angularjs.org/api/ng.$http (see "Response inteceptors" paragraph) | |
//At error function handler: | |
function (response) { | |
//if the user's session is invalid, then the status code is zero. | |
if (response.status == 0) { | |
//Session Invalid! So, you can do anything... typically, you can dispatch a custom event to be handled by some controller | |
//and manipulate your models ou routing state. | |
$rootScope.$emit('redirect_event'); | |
return; | |
} | |
return $q.reject(response); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment