From d8ff73e34f4cbaae18b9926a42d22a0aeda74854 Mon Sep 17 00:00:00 2001 From: agagancarczyk <4890675+agagancarczyk@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:46:21 +0100 Subject: [PATCH] Fixed creating user (#23484) Closes #23327 --- js/apps/admin-ui/src/user/CreateUser.tsx | 17 ++++++++++++++++- js/apps/admin-ui/src/user/UserForm.tsx | 5 ++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/js/apps/admin-ui/src/user/CreateUser.tsx b/js/apps/admin-ui/src/user/CreateUser.tsx index 580f0587f1..24afc2224e 100644 --- a/js/apps/admin-ui/src/user/CreateUser.tsx +++ b/js/apps/admin-ui/src/user/CreateUser.tsx @@ -19,6 +19,8 @@ import { UserFormFields, toUserRepresentation } from "./form-state"; import { toUser } from "./routes/User"; import "./user-section.css"; +import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation"; +import { useFetch } from "../utils/useFetch"; export default function CreateUser() { const { t } = useTranslation(); @@ -28,6 +30,15 @@ export default function CreateUser() { const userForm = useForm({ mode: "onChange" }); const [addedGroups, setAddedGroups] = useState([]); + const [realmRepresentation, setRealmRepresentation] = + useState(); + + useFetch( + () => adminClient.realms.findOne({ realm }), + (result) => setRealmRepresentation(result), + [], + ); + const save = async (data: UserFormFields) => { try { const createdUser = await adminClient.users.create({ @@ -57,7 +68,11 @@ export default function CreateUser() { - + diff --git a/js/apps/admin-ui/src/user/UserForm.tsx b/js/apps/admin-ui/src/user/UserForm.tsx index afbedb7bcc..02cb70480c 100644 --- a/js/apps/admin-ui/src/user/UserForm.tsx +++ b/js/apps/admin-ui/src/user/UserForm.tsx @@ -182,7 +182,6 @@ export const UserForm = ({ filterGroups={selectedGroups} /> )} - {isUserProfileEnabled && } {user?.id && ( <> @@ -224,8 +223,8 @@ export const UserForm = ({ )} - {isUserProfileEnabled ? ( - + {isUserProfileEnabled && user?.userProfileMetadata ? ( + ) : ( <> {!realm?.registrationEmailAsUsername && (