diff --git a/js/apps/admin-ui/src/realm-settings/RealmSettingsTabs.tsx b/js/apps/admin-ui/src/realm-settings/RealmSettingsTabs.tsx index 764c52d098..33b48cb309 100644 --- a/js/apps/admin-ui/src/realm-settings/RealmSettingsTabs.tsx +++ b/js/apps/admin-ui/src/realm-settings/RealmSettingsTabs.tsx @@ -15,6 +15,8 @@ import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import { useAccess } from "../context/access/Access"; +import { fetchWithError } from "@keycloak/keycloak-admin-client"; +import { UserProfileConfig } from "@keycloak/keycloak-admin-client/lib/defs/userProfileMetadata"; import { adminClient } from "../admin-client"; import { useAlerts } from "../components/alert/Alerts"; import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog"; @@ -30,6 +32,8 @@ import { toDashboard } from "../dashboard/routes/Dashboard"; import environment from "../environment"; import helpUrls from "../help-urls"; import { convertFormValuesToObject, convertToFormValues } from "../util"; +import { getAuthorizationHeaders } from "../utils/getAuthorizationHeaders"; +import { joinPath } from "../utils/joinPath"; import useIsFeatureEnabled, { Feature } from "../utils/useIsFeatureEnabled"; import { RealmSettingsEmailTab } from "./EmailTab"; import { RealmSettingsGeneralTab } from "./GeneralTab"; @@ -49,7 +53,6 @@ import { ClientPoliciesTab, toClientPolicies } from "./routes/ClientPolicies"; import { RealmSettingsTab, toRealmSettings } from "./routes/RealmSettings"; import { SecurityDefenses } from "./security-defences/SecurityDefenses"; import { UserProfileTab } from "./user-profile/UserProfileTab"; -import { UserProfileConfig } from "@keycloak/keycloak-admin-client/lib/defs/userProfileMetadata"; export interface UIRealmRepresentation extends RealmRepresentation { upConfig?: UserProfileConfig; @@ -225,7 +228,18 @@ export const RealmSettingsTabs = ({ if (savedRealm.smtpServer?.port === "") { savedRealm.smtpServer = { ...savedRealm.smtpServer, port: null }; } - await adminClient.realms.update({ realm: realmName }, savedRealm); + const response = await fetchWithError( + joinPath(adminClient.baseUrl, `admin/realms/${realmName}/ui-ext`), + { + method: "PUT", + body: JSON.stringify(savedRealm), + headers: { + "Content-Type": "application/json", + ...getAuthorizationHeaders(await adminClient.getAccessToken()), + }, + }, + ); + if (!response.ok) throw new Error(response.statusText); addAlert(t("realmSaveSuccess"), AlertVariant.success); } catch (error) { addError("realmSaveError", error); diff --git a/js/libs/keycloak-admin-client/src/resources/realms.ts b/js/libs/keycloak-admin-client/src/resources/realms.ts index b817082a55..d760cfbf8d 100644 --- a/js/libs/keycloak-admin-client/src/resources/realms.ts +++ b/js/libs/keycloak-admin-client/src/resources/realms.ts @@ -53,7 +53,7 @@ export class Realms extends Resource { void >({ method: "PUT", - path: "/{realm}/ui-ext", + path: "/{realm}", urlParamKeys: ["realm"], });