(fix) more CAS fixes

This commit is contained in:
Ludovic Marcotte 2017-03-01 10:51:01 -05:00
parent 3c46a6ef14
commit 5047aed6ed

View file

@ -259,27 +259,30 @@
function ErrorInterceptor($rootScope, $q, $injector) { function ErrorInterceptor($rootScope, $q, $injector) {
return { return {
responseError: function(rejection) { responseError: function(rejection) {
// Handle CAS ticket renewal // Handle CAS ticket renewal (TODO: add check on usesCASAuthentication)
if (rejection.status == -1) { if (rejection.status == -1) {
var iframe = angular.element('<iframe type="hidden" src="' + UserFolderURL + 'recover"></iframe>'); var deferred = $q.defer();
var iframe = angular.element('<iframe class="ng-hide" src="' + UserFolderURL + 'recover"></iframe>');
iframe.on('load', function() { iframe.on('load', function() {
var $http = $injector.get('$http'); var $http = $injector.get('$http');
if (rejection.config.method == 'GET') { if (rejection.config.method == 'GET') {
return $http({ $http({
method: 'GET', method: 'GET',
url: rejection.config.url url: rejection.config.url
}); }).then(deferred.resolve, deferred.reject);
} }
else if (rejection.config.method == 'POST') { else if (rejection.config.method == 'POST') {
return $http({ $http({
method: 'POST', method: 'POST',
url: rejection.config.url, url: rejection.config.url,
data: rejection.data data: rejection.config.data
}); }).then(deferred.resolve, deferred.reject);
} }
}); });
document.body.appendChild(iframe[0]); document.body.appendChild(iframe[0]);
return deferred.promise;
} }
else { else {
if (/^application\/json/.test(rejection.config.headers.Accept)) { if (/^application\/json/.test(rejection.config.headers.Accept)) {