From 82808e81f2b571100888a4847f54b96d3b70d271 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Wed, 9 Aug 2023 15:43:01 +0200 Subject: [PATCH] keep config if it exists (#22247) fixes: #21960 --- .../src/authentication/FlowDetails.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/apps/admin-ui/src/authentication/FlowDetails.tsx b/js/apps/admin-ui/src/authentication/FlowDetails.tsx index d8fa2df61b..ae0c826640 100644 --- a/js/apps/admin-ui/src/authentication/FlowDetails.tsx +++ b/js/apps/admin-ui/src/authentication/FlowDetails.tsx @@ -1,6 +1,7 @@ import AuthenticationExecutionInfoRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationExecutionInfoRepresentation"; import AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation"; import type { AuthenticationProviderRepresentation } from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation"; +import AuthenticatorConfigRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticatorConfigRepresentation"; import { AlertVariant, Button, @@ -103,12 +104,29 @@ export default function FlowDetails() { try { let id = ex.id!; if ("parent" in change) { + let config: AuthenticatorConfigRepresentation = {}; + if ("authenticationConfig" in ex) { + config = await adminClient.authenticationManagement.getConfig({ + id: ex.authenticationConfig as string, + }); + } + await adminClient.authenticationManagement.delExecution({ id }); const result = await adminClient.authenticationManagement.addExecutionToFlow({ flow: change.parent?.displayName! || flow?.alias!, provider: ex.providerId!, }); + + if (config.id) { + const newConfig = { + id: result.id, + alias: config.alias, + config: config.config, + }; + await adminClient.authenticationManagement.createConfig(newConfig); + } + id = result.id!; } const times = change.newIndex - change.oldIndex;