fixes U4-5430
This commit is contained in:
@@ -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: "/" });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user