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:
parent
e2c9c91080
commit
b8dc051705
3 changed files with 35 additions and 8 deletions
|
@ -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) {
|
||||
|
|
Reference in a new issue