Merge pull request #1959 from coreos-inc/npe-fix

Fix NPE in error interceptor
This commit is contained in:
josephschorr 2016-10-08 01:33:58 +03:00 committed by GitHub
commit c98bec52ad

View file

@ -253,13 +253,6 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi
// Handle session expiration.
Restangular.setErrorInterceptor(function(response) {
//TODO: remove check for error_type (old style errors)
var invalid_token = response.data['title'] == 'invalid_token' || response.data['error_type'] == 'invalid_token';
if (response.status == 401 && invalid_token && response.data['session_required'] !== false) {
$('#sessionexpiredModal').modal({});
return false;
}
if (response.status == 503) {
$('#cannotContactService').modal({});
return false;
@ -270,6 +263,16 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi
return false;
}
if (!response.data) {
return true;
}
var invalid_token = response.data['title'] == 'invalid_token' || response.data['error_type'] == 'invalid_token';
if (response.status == 401 && invalid_token && response.data['session_required'] !== false) {
$('#sessionexpiredModal').modal({});
return false;
}
return true;
});