Fix handling of retrieving the user information and session expiration

This commit is contained in:
Joseph Schorr 2014-03-19 14:04:42 -04:00
parent 6fc369bed2
commit 8ac67e3061

View file

@ -380,7 +380,7 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
}; };
userService.load = function(opt_callback) { userService.load = function(opt_callback) {
ApiService.getLoggedInUser().then(function(loadedUser) { var handleUserResponse = function(loadedUser) {
userResponse = loadedUser; userResponse = loadedUser;
if (!userResponse.anonymous) { if (!userResponse.anonymous) {
@ -410,6 +410,12 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
if (opt_callback) { if (opt_callback) {
opt_callback(); opt_callback();
} }
};
ApiService.getLoggedInUser().then(function(loadedUser) {
handleUserResponse(loadedUser);
}, function() {
handleUserResponse({'anonymous': true});
}); });
}; };
@ -3572,8 +3578,10 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi
// Handle session expiration. // Handle session expiration.
Restangular.setErrorInterceptor(function(response) { Restangular.setErrorInterceptor(function(response) {
if (response.status == 401) { if (response.status == 401) {
$('#sessionexpiredModal').modal({}); if (response.data['session_required'] == null || response.data['session_required'] === true) {
return false; $('#sessionexpiredModal').modal({});
return false;
}
} }
return true; return true;