From 93d4f6031413ebe16e4271e7c02f2db994e532db Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Fri, 12 Dec 2025 21:55:23 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8Fcorrectly=20init=20the=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../proxy/[niceId]/authentication/page.tsx | 91 ++++++++++++++++++- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/src/app/[orgId]/settings/resources/proxy/[niceId]/authentication/page.tsx b/src/app/[orgId]/settings/resources/proxy/[niceId]/authentication/page.tsx index 34087076..b236e1cb 100644 --- a/src/app/[orgId]/settings/resources/proxy/[niceId]/authentication/page.tsx +++ b/src/app/[orgId]/settings/resources/proxy/[niceId]/authentication/page.tsx @@ -232,8 +232,91 @@ export default function ResourceAuthenticationPage() { useEffect(() => { if (!pageLoading || hasInitializedRef.current) return; - usersRolesForm.setValue("roles", allRoles); - usersRolesForm.setValue("users", allUsers); + /** + + + setAllUsers( + usersResponse.data.data.users.map((user) => ({ + id: user.id.toString(), + text: `${user.email || user.username}${user.type !== UserType.Internal ? ` (${user.idpName})` : ""}` + })) + ); + + + whitelistForm.setValue( + "emails", + whitelist.data.data.whitelist.map((w) => ({ + id: w.email, + text: w.email + })) + ); + + if (build === "saas") { + if (subscription?.subscribed) { + setAllIdps( + idpsResponse.data.data.idps.map((idp) => ({ + id: idp.idpId, + text: idp.name + })) + ); + } + } else { + setAllIdps( + idpsResponse.data.data.idps.map((idp) => ({ + id: idp.idpId, + text: idp.name + })) + ); + } + + if ( + autoLoginEnabled && + !selectedIdpId && + idpsResponse.data.data.idps.length > 0 + ) { + setSelectedIdpId(idpsResponse.data.data.idps[0].idpId); + } + + */ + + /** + + usersRolesForm.setValue( + "roles", + resourceRolesResponse.data.data.roles + .map((i) => ({ + id: i.roleId.toString(), + text: i.name + })) + .filter((role) => role.text !== "Admin") + ); + + usersRolesForm.setValue( + "users", + resourceUsersResponse.data.data.users.map((i) => ({ + id: i.userId.toString(), + text: `${i.email || i.username}${i.type !== UserType.Internal ? ` (${i.idpName})` : ""}` + })) + ); + */ + + usersRolesForm.setValue( + "roles", + resourceRoles + .map((i) => ({ + id: i.roleId.toString(), + text: i.name + })) + .filter((role) => role.text !== "Admin") + ); + usersRolesForm.setValue( + "users", + resourceUsers.map((i) => ({ + id: i.userId.toString(), + text: `${i.email || i.username}${i.type !== UserType.Internal ? ` (${i.idpName})` : ""}` + })) + ); + whitelistForm.setValue( "emails", whitelist.map((w) => ({ @@ -247,8 +330,8 @@ export default function ResourceAuthenticationPage() { hasInitializedRef.current = true; }, [ pageLoading, - allRoles, - allUsers, + resourceRoles, + resourceUsers, whitelist, autoLoginEnabled, selectedIdpId,