Skip to content

Commit 8093e11

Browse files
committed
Address PR comments.
1 parent a4e0265 commit 8093e11

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

apps/console/src/public/resources/users/init-impersonate.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"&redirect_uri=" + window.location.origin + window.location.pathname +
3535
"&state=sample_state&scope=internal_user_impersonate&response_type=id_token%20subject_token" +
3636
"&requested_subject=" + userId +
37-
"&nonce=2131236&code_challenge=" + code_challenge + "&code_challenge_method=S256";
37+
"&nonce=" + getNonce() + "&code_challenge=" + code_challenge + "&code_challenge_method=S256";
3838
}
3939
} else {
4040
if (sessionStorage.getItem("impersonation_artifacts") === null) {
@@ -43,6 +43,11 @@
4343
window.parent.postMessage("impersonation-authorize-request-complete", "*");
4444
}
4545
}
46+
47+
function getNonce() {
48+
return Math.floor(Math.random() * (10000000 - 1000000 + 1)) + 1000000;
49+
}
50+
4651
</script>
4752
</body>
4853
</html>

apps/myaccount/src/configs/routes.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,6 @@ export const getAuthLayoutRoutes = (): RouteInterface[] => {
120120
export const getDashboardLayoutRoutes = (): RouteInterface[] => {
121121

122122
return [
123-
{
124-
component: lazy(() => import("../pages/overview")),
125-
exact: true,
126-
icon: <HomeIcon fill="black" />,
127-
id: "overview",
128-
name: "common:overview",
129-
path: AppConstants.getPaths().get("OVERVIEW"),
130-
protected: true,
131-
showOnSidePanel: true
132-
},
133123
{
134124
component: lazy(() => import("../pages/applications")),
135125
exact: true,
@@ -140,6 +130,16 @@ export const getDashboardLayoutRoutes = (): RouteInterface[] => {
140130
protected: true,
141131
showOnSidePanel: true
142132
},
133+
{
134+
component: lazy(() => import("../pages/overview")),
135+
exact: true,
136+
icon: <HomeIcon fill="black" />,
137+
id: "overview",
138+
name: "common:overview",
139+
path: AppConstants.getPaths().get("OVERVIEW"),
140+
protected: true,
141+
showOnSidePanel: true
142+
},
143143
{
144144
component: lazy(() => import("../pages/personal-info")),
145145
exact: true,

apps/myaccount/src/layouts/dashboard.tsx

+15-4
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.
@@ -259,7 +269,8 @@ export const DashboardLayout: FunctionComponent<PropsWithChildren<DashboardLayou
259269
icon: route.icon,
260270
label: t(route.name),
261271
onClick: () => history.push(route.path),
262-
selected: selectedRoute?.path === route.path
272+
selected: selectedRoute?.path === route.path,
273+
showOnSidePanel: false
263274
};
264275
}
265276
),

features/admin.users.v1/components/user-impersonation-action.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
import { HttpResponse, useAuthContext } from "@asgardeo/auth-react";
20-
import Button from "@oxygen-ui/react/Button";
2120
import { AppState } from "@wso2is/admin.core.v1/store";
2221
import { SCIMConfigs } from "@wso2is/admin.extensions.v1";
2322
import { administratorConfig } from "@wso2is/admin.extensions.v1/configs/administrator";

0 commit comments

Comments
 (0)