From ea4f122a739dbfcee1961160047fb8d93c70559e Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 22 Jun 2022 10:50:47 +0200 Subject: [PATCH] Use realm id instead of realm name as parentId (#2836) --- .../custom/CustomProviderSettings.tsx | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/user-federation/custom/CustomProviderSettings.tsx b/src/user-federation/custom/CustomProviderSettings.tsx index 73323797ab..1f2ae97691 100644 --- a/src/user-federation/custom/CustomProviderSettings.tsx +++ b/src/user-federation/custom/CustomProviderSettings.tsx @@ -1,5 +1,5 @@ -import React from "react"; -import { useHistory, useParams } from "react-router-dom"; +import React, { useState } from "react"; +import { Link, useHistory, useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { FormProvider, useForm } from "react-hook-form"; import { @@ -41,7 +41,8 @@ export default function CustomProviderSettings() { const adminClient = useAdminClient(); const { addAlert, addError } = useAlerts(); - const { realm } = useRealm(); + const { realm: realmName } = useRealm(); + const [parentId, setParentId] = useState(""); useFetch( async () => { @@ -60,17 +61,26 @@ export default function CustomProviderSettings() { [] ); + useFetch( + () => + adminClient.realms.findOne({ + realm: realmName, + }), + (realm) => setParentId(realm?.id!), + [] + ); + const save = async (component: ComponentRepresentation) => { const saveComponent = { ...component, providerId, providerType: "org.keycloak.storage.UserStorageProvider", - parentId: realm, + parentId, }; try { if (!id) { await adminClient.components.create(saveComponent); - history.push(toUserFederation({ realm })); + history.push(toUserFederation({ realm: realmName })); } else { await adminClient.components.update({ id }, saveComponent); } @@ -128,7 +138,9 @@ export default function CustomProviderSettings() {