From ed23bd40d277e1d22aca635a56f6505d134ab609 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Fri, 9 Feb 2024 09:50:20 -0800 Subject: [PATCH] Redirect to SAML portal upon enforcing SAML SSO --- .../OrgAuthTab/OrgGeneralAuthSection.tsx | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx index 56187acec..80fd890a1 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx @@ -1,15 +1,14 @@ -import { useRouter } from "next/router"; - import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { OrgPermissionCan } from "@app/components/permissions"; import { Switch } from "@app/components/v2"; -import { OrgPermissionActions, +import { + OrgPermissionActions, OrgPermissionSubjects, -useOrganization } from "@app/context"; + useOrganization +} from "@app/context"; import { useLogoutUser,useUpdateOrg } from "@app/hooks/api"; export const OrgGeneralAuthSection = () => { - const router = useRouter(); const { createNotification } = useNotificationContext(); const { currentOrg } = useOrganization(); @@ -17,16 +16,6 @@ export const OrgGeneralAuthSection = () => { const logout = useLogoutUser(); - const logOutUser = async () => { - try { - console.log("Logging out..."); - await logout.mutateAsync(); - router.push("/login"); - } catch (error) { - console.error(error); - } - }; - const handleEnforceOrgAuthToggle = async (value: boolean) => { try { if (!currentOrg?.id) return; @@ -42,7 +31,10 @@ export const OrgGeneralAuthSection = () => { }); if (value) { - logOutUser(); + await logout.mutateAsync(); + window.open(`/api/v1/sso/redirect/saml2/organizations/${currentOrg.slug}`); + window.close(); + return; } } catch (err) {