Skip to content

Instantly share code, notes, and snippets.

@gjohnson
Created May 8, 2013 20:13
Show Gist options
  • Select an option

  • Save gjohnson/5543290 to your computer and use it in GitHub Desktop.

Select an option

Save gjohnson/5543290 to your computer and use it in GitHub Desktop.
Handle session timeouts within ajax calls nicely.
$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