From 58db323eee2b7bfee0b6ab556d0960d45cc56b45 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 23 Sep 2014 12:40:30 +1000 Subject: [PATCH] fixes U4-5430 --- src/Umbraco.Web.UI.Client/src/routes.js | 36 +++++++++---------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/routes.js b/src/Umbraco.Web.UI.Client/src/routes.js index 6f89b51e9b..3f4b28597d 100644 --- a/src/Umbraco.Web.UI.Client/src/routes.js +++ b/src/Umbraco.Web.UI.Client/src/routes.js @@ -26,35 +26,25 @@ app.config(function ($routeProvider) { //This could be the first time has loaded after the user has logged in, in this case // we need to broadcast the authenticated event - this will be handled by the startup (init) // handler to set/broadcast the ready state - if (appState.getGlobalState("isReady") !== true) { - userService.getCurrentUser({ broadcastEvent: true }).then(function(user) { - //is auth, check if we allow or reject - if (isRequired) { - // U4-5430, Benjamin Howarth - // We need to change the current route params if the user only has access to a single section - // To do this we need to grab the current user's allowed sections, then reject the promise with the correct path. - if (user.allowedSections.indexOf($route.current.params.section) > -1) { - //this will resolve successfully so the route will continue - deferred.resolve(true); - } else { - deferred.reject({ path: "/" + user.allowedSections[0] }); - } - } - else { - deferred.reject({ path: "/" }); - } - }); - } - else { + var broadcast = appState.getGlobalState("isReady") !== true; + + userService.getCurrentUser({ broadcastEvent: broadcast }).then(function (user) { //is auth, check if we allow or reject if (isRequired) { - //this will resolve successfully so the route will continue - deferred.resolve(true); + // U4-5430, Benjamin Howarth + // We need to change the current route params if the user only has access to a single section + // To do this we need to grab the current user's allowed sections, then reject the promise with the correct path. + if (user.allowedSections.indexOf($route.current.params.section) > -1) { + //this will resolve successfully so the route will continue + deferred.resolve(true); + } else { + deferred.reject({ path: "/" + user.allowedSections[0] }); + } } else { deferred.reject({ path: "/" }); } - } + }); });