Skip to content

Commit

Permalink
update realm when changing bind (keycloak#31133)
Browse files Browse the repository at this point in the history
* update realm when changing bind

Signed-off-by: Erik Jan de Wit <[email protected]>

* also update used by label

Signed-off-by: Erik Jan de Wit <[email protected]>

---------

Signed-off-by: Erik Jan de Wit <[email protected]>
  • Loading branch information
edewit authored Jul 11, 2024
1 parent 88725cd commit 2bd17cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ export default function AuthenticationSection() {
{
name: "usedBy",
displayKey: "usedBy",
cellRenderer: (row) => (
<UsedBy authType={row} realm={realm} />
),
cellRenderer: (row) => <UsedBy authType={row} />,
},
{
name: "description",
Expand Down
5 changes: 2 additions & 3 deletions js/apps/admin-ui/src/authentication/BindFlowDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ export const BindFlowDialog = ({ flowAlias, onClose }: BindFlowDialogProps) => {
const { t } = useTranslation();
const form = useForm<BindingForm>();
const { addAlert, addError } = useAlerts();
const { realm } = useRealm();
const { realm, realmRepresentation: realmRep, refresh } = useRealm();

const onSubmit = async ({ bindingType }: BindingForm) => {
const realmRep = await adminClient.realms.findOne({ realm });

try {
await adminClient.realms.update(
{ realm },
{ ...realmRep, [bindingType]: flowAlias },
);
refresh();
addAlert(t("updateFlowSuccess"), AlertVariant.success);
} catch (error) {
addError("updateFlowError", error);
Expand Down
8 changes: 4 additions & 4 deletions js/apps/admin-ui/src/authentication/components/UsedBy.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
import {
Button,
Modal,
Expand All @@ -17,10 +16,10 @@ import useToggle from "../../utils/useToggle";
import { AuthenticationType, REALM_FLOWS } from "../AuthenticationSection";

import style from "./used-by.module.css";
import { useRealm } from "../../context/realm-context/RealmContext";

type UsedByProps = {
authType: AuthenticationType;
realm: RealmRepresentation;
};

const Label = ({ label }: { label: string }) => (
Expand Down Expand Up @@ -96,11 +95,12 @@ const UsedByModal = ({ id, isSpecificClient, onClose }: UsedByModalProps) => {
);
};

export const UsedBy = ({ authType: { id, usedBy }, realm }: UsedByProps) => {
export const UsedBy = ({ authType: { id, usedBy } }: UsedByProps) => {
const { t } = useTranslation();
const { realmRepresentation: realm } = useRealm();
const [open, toggle] = useToggle();

const key = Object.entries(realm).find(
const key = Object.entries(realm!).find(
(e) => e[1] === usedBy?.values[0],
)?.[0];

Expand Down

0 comments on commit 2bd17cd

Please sign in to comment.