From 7c1e2afe73159d1378c92fb60d8b9c7b343b10fc Mon Sep 17 00:00:00 2001 From: Zach Waterfield Date: Thu, 5 Dec 2024 16:21:40 -0500 Subject: [PATCH] Only allow admins/owners to toggle 2FA --- frontend/src/scenes/settings/organization/Members.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/scenes/settings/organization/Members.tsx b/frontend/src/scenes/settings/organization/Members.tsx index 00d8bf08bc8e4..748e5d69f1b90 100644 --- a/frontend/src/scenes/settings/organization/Members.tsx +++ b/frontend/src/scenes/settings/organization/Members.tsx @@ -1,6 +1,7 @@ import { LemonInput, LemonModal, LemonSwitch } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' import { PayGateMini } from 'lib/components/PayGateMini/PayGateMini' +import { useRestrictedArea } from 'lib/components/RestrictedArea' import { TZLabel } from 'lib/components/TZLabel' import { OrganizationMembershipLevel } from 'lib/constants' import { LemonButton } from 'lib/lemon-ui/LemonButton' @@ -145,6 +146,8 @@ export function Members(): JSX.Element | null { const { preflight } = useValues(preflightLogic) const { user } = useValues(userLogic) + const twoFactorRestrictionReason = useRestrictedArea({ minimumAccessLevel: OrganizationMembershipLevel.Admin }) + useEffect(() => { ensureAllMembersLoaded() }, []) @@ -300,6 +303,7 @@ export function Members(): JSX.Element | null { bordered checked={!!currentOrganization?.enforce_2fa} onChange={(enforce_2fa) => updateOrganization({ enforce_2fa })} + disabledReason={twoFactorRestrictionReason} />