diff --git a/src/Umbraco.Web.UI.Client/src/common/interceptors/security.interceptor.js b/src/Umbraco.Web.UI.Client/src/common/interceptors/security.interceptor.js index d187714c62..30daaf5837 100644 --- a/src/Umbraco.Web.UI.Client/src/common/interceptors/security.interceptor.js +++ b/src/Umbraco.Web.UI.Client/src/common/interceptors/security.interceptor.js @@ -59,20 +59,27 @@ } //A 401 means that the user is not logged in - if (rejection.status === 401 && !rejection.config.url.endsWith("umbraco/backoffice/UmbracoApi/Authentication/GetCurrentUser")) { + if (rejection.status === 401) { + //avoid an infinite loop + var umbRequestHelper = $injector.get('umbRequestHelper'); + var getCurrentUserPath = umbRequestHelper.getApiUrl("authenticationApiBaseUrl", "GetCurrentUser"); + if (!rejection.config.url.endsWith(getCurrentUserPath)) { - var userService = $injector.get('userService'); // see above + var userService = $injector.get('userService'); // see above - //Associate the user name with the retry to ensure we retry for the right user - return userService.getCurrentUser() - .then(function (user) { - var userName = user ? user.name : null; - //The request bounced because it was not authorized - add a new request to the retry queue - return requestRetryQueue.pushRetryFn('unauthorized-server', userName, function retryRequest() { - // We must use $injector to get the $http service to prevent circular dependency - return $injector.get('$http')(rejection.config); + //Associate the user name with the retry to ensure we retry for the right user + return userService.getCurrentUser() + .then(function(user) { + var userName = user ? user.name : null; + //The request bounced because it was not authorized - add a new request to the retry queue + return requestRetryQueue.pushRetryFn('unauthorized-server', + userName, + function retryRequest() { + // We must use $injector to get the $http service to prevent circular dependency + return $injector.get('$http')(rejection.config); + }); }); - }); + } } else if (rejection.status === 404) {