mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1119: Redirect to login ONLY for requests to /api/tokens, and ONLY if not already at login.
This commit is contained in:
@@ -24,17 +24,24 @@ angular.module('index').factory('authenticationInterceptor', ['$location', '$q',
|
|||||||
function authenticationInterceptor($location, $q) {
|
function authenticationInterceptor($location, $q) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'response': function(response) {
|
|
||||||
return response || $q.when(response);
|
|
||||||
},
|
|
||||||
|
|
||||||
'responseError': function(rejection) {
|
// Redirect users to login if authorization fails
|
||||||
// Do not redirect failed api requests.
|
responseError: function handleErrorResponse(rejection) {
|
||||||
|
|
||||||
|
// Only redirect failed authentication requests
|
||||||
if ((rejection.status === 401 || rejection.status === 403)
|
if ((rejection.status === 401 || rejection.status === 403)
|
||||||
&& rejection.config.url.search('api/') === -1) {
|
&& rejection.config.url === 'api/tokens') {
|
||||||
$location.path('/login');
|
|
||||||
|
// Only redirect if not already on login page
|
||||||
|
if ($location.path() !== '/login/')
|
||||||
|
$location.path('/login/');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $q.reject(rejection);
|
return $q.reject(rejection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
Reference in New Issue
Block a user