Change 403 handling to 401 and have a modal dialog (that cannot be removed) display when the user's session has expired. This forces them to reload the page, and thus reset all the state.

This commit is contained in:
Joseph Schorr 2013-11-11 19:26:56 -05:00
parent e2c9c91080
commit b8dc051705
3 changed files with 35 additions and 8 deletions

View file

@ -60,7 +60,7 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
var userService = {}
userService.load = function() {
userService.load = function(opt_callback) {
var userFetch = Restangular.one('user/');
userFetch.get().then(function(loadedUser) {
userResponse = loadedUser;
@ -76,6 +76,10 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
'$created': new Date()
})
}
if (opt_callback) {
opt_callback();
}
});
};
@ -868,11 +872,13 @@ quayApp.directive('ngBlur', function() {
});
quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', function($location, $rootScope, Restangular, UserService) {
Restangular.setResponseInterceptor(function(data, operation, what, url, response, deferred) {
if (response.status == 403) {
UserService.load();
Restangular.setErrorInterceptor(function(response) {
if (response.status == 401) {
$('#sessionexpiredModal').modal({});
return false;
}
return data;
return true;
});
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {