Use correct path to account console
Fixes: #27709 Signed-off-by: Hynek Mlnarik <hmlnarik@redhat.com>
This commit is contained in:
parent
4091baf4c2
commit
26468e11f2
5 changed files with 9 additions and 8 deletions
|
@ -150,6 +150,7 @@
|
|||
<script id="environment" type="application/json">
|
||||
{
|
||||
"authUrl": "${authUrl}",
|
||||
"baseUrl": "${baseUrl}",
|
||||
"realm": "${realm.name}",
|
||||
"clientId": "${clientId}",
|
||||
"resourceUrl": "${resourceUrl}",
|
||||
|
|
|
@ -18,6 +18,8 @@ export type Feature = {
|
|||
export type Environment = {
|
||||
/** The URL to the root of the auth server. */
|
||||
authUrl: string;
|
||||
/** The URL to the root of the account console. */
|
||||
baseUrl: string;
|
||||
/** The realm used to authenticate the user to the Account Console. */
|
||||
realm: string;
|
||||
/** The identifier of the client used to authenticate the user to the Account Console. */
|
||||
|
@ -39,6 +41,7 @@ const match = matchPath(ROOT_PATH, location.pathname);
|
|||
|
||||
const defaultEnvironment: Environment = {
|
||||
authUrl: "http://localhost:8180",
|
||||
baseUrl: `http://localhost:8180/realms/${match?.params.realm ?? DEFAULT_REALM}/account`,
|
||||
realm: match?.params.realm ?? DEFAULT_REALM,
|
||||
clientId: "security-admin-console-v2",
|
||||
resourceUrl: "http://localhost:8080",
|
||||
|
|
|
@ -20,14 +20,12 @@ import {
|
|||
useHref,
|
||||
useLinkClickHandler,
|
||||
useLocation,
|
||||
useParams,
|
||||
} from "react-router-dom";
|
||||
import fetchContentJson from "../content/fetchContent";
|
||||
import type { Feature } from "../environment";
|
||||
import { environment, type Feature } from "../environment";
|
||||
import { TFuncKey } from "../i18n";
|
||||
import { usePromise } from "../utils/usePromise";
|
||||
import { useEnvironment } from "./KeycloakContext";
|
||||
import { getRootPath } from "../utils/getRootPath";
|
||||
|
||||
type RootMenuItem = {
|
||||
label: TFuncKey;
|
||||
|
@ -134,9 +132,7 @@ export const NavLink = ({
|
|||
isActive,
|
||||
children,
|
||||
}: PropsWithChildren<NavLinkProps>) => {
|
||||
const { realm } = useParams();
|
||||
|
||||
const menuItemPath = `${getRootPath(realm)}/${to}`;
|
||||
const menuItemPath = `${new URL(environment.baseUrl).pathname}${to}`;
|
||||
const href = useHref(menuItemPath);
|
||||
const handleClick = useLinkClickHandler(menuItemPath);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import type { IndexRouteObject, RouteObject } from "react-router-dom";
|
|||
|
||||
import { ErrorPage } from "./root/ErrorPage";
|
||||
import { Root } from "./root/Root";
|
||||
import { environment } from "./environment";
|
||||
|
||||
const DeviceActivity = lazy(() => import("./account-security/DeviceActivity"));
|
||||
const LinkedAccounts = lazy(() => import("./account-security/LinkedAccounts"));
|
||||
|
@ -58,7 +59,7 @@ export const PersonalInfoRoute: IndexRouteObject = {
|
|||
};
|
||||
|
||||
export const RootRoute: RouteObject = {
|
||||
path: "/realms/:realm/account",
|
||||
path: new URL(environment.baseUrl).pathname,
|
||||
element: <Root />,
|
||||
errorElement: <ErrorPage />,
|
||||
children: [
|
||||
|
|
|
@ -103,7 +103,7 @@ public class AccountConsole implements AccountResourceProvider {
|
|||
URI adminBaseUri = session.getContext().getUri(UrlType.ADMIN).getBaseUri();
|
||||
URI authUrl = uriInfo.getBaseUri();
|
||||
map.put("authUrl", authUrl.getPath().endsWith("/") ? authUrl : authUrl + "/");
|
||||
map.put("baseUrl", accountBaseUrl);
|
||||
map.put("baseUrl", accountBaseUrl.getPath().endsWith("/") ? accountBaseUrl : accountBaseUrl + "/");
|
||||
map.put("realm", realm);
|
||||
map.put("clientId", Constants.ACCOUNT_CONSOLE_CLIENT_ID);
|
||||
map.put("resourceUrl", Urls.themeRoot(authUrl).getPath() + "/" + Constants.ACCOUNT_MANAGEMENT_CLIENT_ID + "/" + theme.getName());
|
||||
|
|
Loading…
Reference in a new issue