(js) Improve CAS handling
This commit is contained in:
parent
a29ced853a
commit
a3d7ae3a6b
|
@ -259,38 +259,27 @@
|
||||||
function ErrorInterceptor($rootScope, $q, $injector) {
|
function ErrorInterceptor($rootScope, $q, $injector) {
|
||||||
return {
|
return {
|
||||||
responseError: function(rejection) {
|
responseError: function(rejection) {
|
||||||
// Handle CAS ticket renewal (TODO: add check on usesCASAuthentication)
|
var deferred, iframe;
|
||||||
if (rejection.status == -1) {
|
// Handle CAS ticket renewal (TODO: add check on usesCASAuthentication)
|
||||||
var deferred = $q.defer();
|
if (rejection.status == -1) {
|
||||||
var iframe = angular.element('<iframe class="ng-hide" src="' + UserFolderURL + 'recover"></iframe>');
|
deferred = $q.defer();
|
||||||
|
iframe = angular.element('<iframe class="ng-hide" src="' + UserFolderURL + 'recover"></iframe>');
|
||||||
iframe.on('load', function() {
|
iframe.on('load', function() {
|
||||||
var $http = $injector.get('$http');
|
// Once the browser has followed the redirection, send the initial request
|
||||||
|
var $http = $injector.get('$http');
|
||||||
if (rejection.config.method == 'GET') {
|
$http(rejection.config).then(deferred.resolve, deferred.reject);
|
||||||
$http({
|
iframe.remove();
|
||||||
method: 'GET',
|
});
|
||||||
url: rejection.config.url
|
document.body.appendChild(iframe[0]);
|
||||||
}).then(deferred.resolve, deferred.reject);
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
else if (rejection.config.method == 'POST') {
|
else {
|
||||||
$http({
|
if (/^application\/json/.test(rejection.config.headers.Accept)) {
|
||||||
method: 'POST',
|
// Broadcast the response error
|
||||||
url: rejection.config.url,
|
$rootScope.$broadcast('http:Error', rejection);
|
||||||
data: rejection.config.data
|
|
||||||
}).then(deferred.resolve, deferred.reject);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
document.body.appendChild(iframe[0]);
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (/^application\/json/.test(rejection.config.headers.Accept)) {
|
|
||||||
// Broadcast the response error
|
|
||||||
$rootScope.$broadcast('http:Error', rejection);
|
|
||||||
}
|
|
||||||
return $q.reject(rejection);
|
|
||||||
}
|
}
|
||||||
|
return $q.reject(rejection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue