Skip to content

Commit d329c55

Browse files
committed
Show only Applications section when myaccount impersonation.
1 parent 82d4ff5 commit d329c55

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

apps/myaccount/src/layouts/dashboard.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const DashboardLayout: FunctionComponent<PropsWithChildren<DashboardLayou
9696
const [ announcement, setAnnouncement ] = useState<AnnouncementBannerInterface>();
9797
const [ showAnnouncement, setShowAnnouncement ] = useState<boolean>(true);
9898
const [ dashboardLayoutRoutes, setDashboardLayoutRoutes ] = useState<RouteInterface[]>(getDashboardLayoutRoutes());
99+
const allowedScopes: string = useSelector((state: AppState) => state?.authenticationInformation?.scope);
99100

100101
useEffect(() => {
101102
const localeCookie: string = CookieStorageUtils.getItem("ui_lang");
@@ -161,15 +162,24 @@ export const DashboardLayout: FunctionComponent<PropsWithChildren<DashboardLayou
161162
}
162163

163164
const routes: RouteInterface[] = getDashboardLayoutRoutes().filter((route: RouteInterface) => {
164-
if (route.path === AppConstants.getPaths().get("APPLICATIONS") && !isApplicationsPageVisible) {
165-
return false;
165+
166+
if (allowedScopes.includes("internal_user_impersonate")) {
167+
if (route.path === "/") {
168+
route.redirectTo = AppConstants.getPaths().get("APPLICATIONS");
169+
} else if (route.path != AppConstants.getPaths().get("APPLICATIONS")) {
170+
return false;
171+
}
172+
} else {
173+
if (route.path === AppConstants.getPaths().get("APPLICATIONS") && !isApplicationsPageVisible) {
174+
return false;
175+
}
166176
}
167177

168178
return route;
169179
});
170180

171181
setDashboardLayoutRoutes(filterRoutes(routes, config.ui?.features));
172-
}, [ AppConstants.getTenantQualifiedAppBasename(), config, isApplicationsPageVisible ]);
182+
}, [ AppConstants.getTenantQualifiedAppBasename(), config, isApplicationsPageVisible, allowedScopes ]);
173183

174184
/**
175185
* On location change, update the selected route.

0 commit comments

Comments
 (0)