Created
May 8, 2013 20:13
-
-
Save gjohnson/5543290 to your computer and use it in GitHub Desktop.
Handle session timeouts within ajax calls nicely.
This file contains hidden or 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
| $httpProvider.responseInterceptors.push(function($window){ | |
| return function(promise){ | |
| return promise.then(function(){ | |
| // session is valid, carry along... | |
| return promise; | |
| }, function(error){ | |
| if (error.status == 401) { | |
| // invalid session, need to re-login... | |
| $window.location = '/login'; | |
| } | |
| }); | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment