Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add feature flag for MFA.

Ivan Vasilov78497508c417
diff --git a/studio/components/layouts/AccountLayout/AccountLayout.tsx b/studio/components/layouts/AccountLayout/AccountLayout.tsx
index 30b45d09505..7a8dbe4dae2 100644
--- a/studio/components/layouts/AccountLayout/AccountLayout.tsx
+++ b/studio/components/layouts/AccountLayout/AccountLayout.tsx
@@ -3,6 +3,7 @@ import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
+import { useMfaListFactorsQuery } from 'data/profile/mfa-list-factors-query'
import { useFlag, useSelectedOrganization, withAuth } from 'hooks'
import { useSignOut } from 'lib/auth'
import { IS_PLATFORM } from 'lib/constants'
@@ -22,9 +23,11 @@ const AccountLayout = ({ children, title, breadcrumbs }: PropsWithChildren<Accou
const router = useRouter()
const { data: organizations } = useOrganizationsQuery()
const selectedOrganization = useSelectedOrganization()
+ const { data: factors } = useMfaListFactorsQuery()
const ongoingIncident = useFlag('ongoingIncident')
const navLayoutV2 = useFlag('navigationLayoutV2')
+ const mfaSetup = useFlag('mfaSetup')
const maxHeight = ongoingIncident ? 'calc(100vh - 44px)' : '100vh'
const signOut = useSignOut()
@@ -78,13 +81,19 @@ const AccountLayout = ({ children, title, breadcrumbs }: PropsWithChildren<Accou
href: `/account/me`,
key: `/account/me`,
},
- {
- isActive: router.pathname === `/account/security`,
- icon: `${router.basePath}/img/user.svg`,
- label: 'Security',
- href: `/account/security`,
- key: `/account/security`,
- },
+ // show the MFA page only if the feature flag is set or the user has already MFA setup.
+ // He should be able to edit/revoke his MFA even if MFA feature flag is disabled.
+ ...(mfaSetup || (factors?.all || []).length > 0
+ ? [
+ {
+ isActive: router.pathname === `/account/security`,
+ icon: `${router.basePath}/img/user.svg`,
+ label: 'Security',
+ href: `/account/security`,
+ key: `/account/security`,
+ },
+ ]
+ : []),
{
isActive: router.pathname === `/account/tokens`,
icon: `${router.basePath}/img/user.svg`,