From d185dbb7ff0ecb4b1cb6b7c10d3abcc82b01157f Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Thu, 22 May 2025 01:00:13 +0800 Subject: [PATCH] misc: add proper error message for bypass failure --- .../auth/SelectOrgPage/SelectOrgSection.tsx | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx index 2ca179c87..a736b52a7 100644 --- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx +++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx @@ -70,10 +70,25 @@ export const SelectOrganizationSection = () => { const handleSelectOrganization = useCallback( async (organization: Organization) => { - const canBypassOrgAuth = - organization.bypassOrgAuthEnabled && - organization.userRole === OrgMembershipRole.Admin && - isAdminLogin; + const isUserOrgAdmin = organization.userRole === OrgMembershipRole.Admin; + const canBypassOrgAuth = organization.bypassOrgAuthEnabled && isUserOrgAdmin && isAdminLogin; + + if (isAdminLogin) { + if (!organization.bypassOrgAuthEnabled) { + createNotification({ + text: "This organization does not have bypass org auth enabled", + type: "error" + }); + return; + } + if (!isUserOrgAdmin) { + createNotification({ + text: "Only organization admins can bypass org auth", + type: "error" + }); + return; + } + } if (organization.authEnforced && !canBypassOrgAuth) { // org has an org-level auth method enabled (e.g. SAML)