import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { FormControl, Select, SelectItem, Switch } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization, useSubscription } from "@app/context"; import { useUpdateOrg } from "@app/hooks/api"; import { MfaMethod } from "@app/hooks/api/auth/types"; import { usePopUp } from "@app/hooks/usePopUp"; export const OrgGenericAuthSection = () => { const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const); const { mutateAsync } = useUpdateOrg(); const handleEnforceMfaToggle = async (value: boolean) => { try { if (!currentOrg?.id) return; if (!subscription?.enforceMfa) { handlePopUpOpen("upgradePlan"); return; } await mutateAsync({ orgId: currentOrg?.id, enforceMfa: value }); createNotification({ text: `Successfully ${value ? "enforced" : "un-enforced"} MFA`, type: "success" }); } catch (err) { console.error(err); createNotification({ text: (err as { response: { data: { message: string } } }).response.data.message, type: "error" }); } }; const handleUpdateSelectedMfa = async (selectedMfaMethod: MfaMethod) => { try { if (!currentOrg?.id) return; if (!subscription?.enforceMfa) { handlePopUpOpen("upgradePlan"); return; } await mutateAsync({ orgId: currentOrg?.id, selectedMfaMethod }); createNotification({ text: "Successfully updated selected MFA method", type: "success" }); } catch (err) { console.error(err); createNotification({ text: (err as { response: { data: { message: string } } }).response.data.message, type: "error" }); } }; return (
Enforce members to authenticate with MFA in order to access the organization
{currentOrg?.enforceMfa && (