(fix) first pass at CAS XHR issue
This commit is contained in:
parent
6b471994ef
commit
af3a35169a
|
@ -255,16 +255,40 @@
|
||||||
/**
|
/**
|
||||||
* @ngInject
|
* @ngInject
|
||||||
*/
|
*/
|
||||||
ErrorInterceptor.$inject = ['$rootScope', '$q'];
|
ErrorInterceptor.$inject = ['$rootScope', '$q', '$injector'];
|
||||||
function ErrorInterceptor($rootScope, $q) {
|
function ErrorInterceptor($rootScope, $q, $injector) {
|
||||||
return {
|
return {
|
||||||
responseError: function(rejection) {
|
responseError: function(rejection) {
|
||||||
|
// Handle CAS ticket renewal
|
||||||
|
if (rejection.status == -1) {
|
||||||
|
var iframe = angular.element('<iframe type="hidden" src="' + UserFolderURL + 'recover"></iframe>');
|
||||||
|
iframe.on('load', function() {
|
||||||
|
var $http = $injector.get('$http');
|
||||||
|
|
||||||
|
if (rejection.config.method == 'GET') {
|
||||||
|
return $http({
|
||||||
|
method: 'GET',
|
||||||
|
url: rejection.config.url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (rejection.config.method == 'POST') {
|
||||||
|
return $http({
|
||||||
|
method: 'POST',
|
||||||
|
url: rejection.config.url,
|
||||||
|
data: rejection.data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.body.appendChild(iframe[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (/^application\/json/.test(rejection.config.headers.Accept)) {
|
if (/^application\/json/.test(rejection.config.headers.Accept)) {
|
||||||
// Broadcast the response error
|
// Broadcast the response error
|
||||||
$rootScope.$broadcast('http:Error', rejection);
|
$rootScope.$broadcast('http:Error', rejection);
|
||||||
}
|
}
|
||||||
return $q.reject(rejection);
|
return $q.reject(rejection);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue