From 550f18b05003073eaa0bca2145801bcdedaacb2e Mon Sep 17 00:00:00 2001 From: Efekan <142125914+efekanbahceci@users.noreply.github.com> Date: Tue, 13 Oct 2026 10:59:32 +0300 Subject: [PATCH] fix(studio): clarify authenticator app name and add direct support link during MFA sign-in (#51531) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem When users set up two-factor authentication (TOTP) in the dashboard, the enrollment modal asks them to name their authenticator app, with the placeholder suggesting `e.g.: Google Authenticator`. Many users keep or type this example name without realizing it is simply a custom nickname for the factor. On the sign-in MFA screen (`SignInMfaForm.tsx`), the code input previously rendered its label as: > `Code generated by Google Authenticator` This phrasing can lead users to believe that Supabase has locked their account specifically to Google's authenticator app—even when they actually scanned the QR code with Apple Passwords / iOS Keychain, 1Password, or Bitwarden. As reported in #51502, users who rely on their iPhone's built-in authenticator can get alarmed, thinking their authentication setup was unexpectedly swapped. Furthermore, if a user is genuinely locked out (e.g. lost device and backup codes), the "Email support" option previously only surfaced after an explicit authentication exception occurred, rather than being readily discoverable under the *"Unable to sign in?"* help section. Closes #51502 ## Solution 1. **Clear, standard form label & descriptive subtext**: - Replaced the ambiguous `Code generated by [Friendly Name]` label with a standard `Authentication code` label. - Moved the factor's friendly name into the field description: - When a name is configured: `From the authenticator app registered as [Friendly Name]` - Fallback when no name is set: `From the authenticator app registered to this account` - This makes it immediately obvious that `[Friendly Name]` is just the custom label they chose, rather than a hard vendor requirement. 2. **Direct support escape hatch**: - Added an **"Email support to regain access"** link directly into the *"Unable to sign in?"* list in both `SignInMfaForm` and `SignInRecoveryCodeForm`. - Users who are stuck now have an immediate, obvious way to reach out without needing to trigger errors or hunt down the support email. 3. **Extracted testable helper logic**: - Extracted friendly-name normalization and support mailto generation into a dedicated `SignInMfa.utils.ts` module. - Added unit test coverage in `SignInMfa.utils.test.ts` (9 tests covering trims, null/empty cases, and mailto parameters). ## Review instructions 1. Navigate to `/sign-in-mfa` (with an account that has a TOTP factor enrolled). 2. Verify that the input label reads `Authentication code`. 3. Check the subtext: verify that it clarifies `From the authenticator app registered as [Name]`. 4. Inspect the *"Unable to sign in?"* section at the bottom: - Confirm that "Email support to regain access" is visible and opens a pre-addressed email to `support@supabase.com` with subject `Unable to sign in via MFA`. 5. Check `/sign-in-recovery-code` and verify the same support link is present. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] Unit tests added and passing (`vitest run components/interfaces/SignIn/SignInMfa.utils.test.ts`) - [x] Code passes Prettier formatting check - [x] Code passes ESLint without adding warnings --- .../interfaces/SignIn/SignInMfa.utils.test.ts | 45 +++++++++++++++++++ .../interfaces/SignIn/SignInMfa.utils.ts | 20 +++++++++ .../interfaces/SignIn/SignInMfaForm.tsx | 38 +++++++++------- .../SignIn/SignInRecoveryCodeForm.tsx | 13 ++++-- 4 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 apps/studio/components/interfaces/SignIn/SignInMfa.utils.test.ts create mode 100644 apps/studio/components/interfaces/SignIn/SignInMfa.utils.ts diff --git a/apps/studio/components/interfaces/SignIn/SignInMfa.utils.test.ts b/apps/studio/components/interfaces/SignIn/SignInMfa.utils.test.ts new file mode 100644 index 00000000000..dbc48579ac2 --- /dev/null +++ b/apps/studio/components/interfaces/SignIn/SignInMfa.utils.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, test } from 'vitest' + +import { + getFactorDisplayName, + getFactorFriendlyName, + MFA_SUPPORT_EMAIL_HREF, +} from './SignInMfa.utils' + +describe('getFactorFriendlyName', () => { + test('returns the trimmed friendly name', () => { + expect(getFactorFriendlyName({ friendly_name: ' iPhone Passwords ' })).toBe( + 'iPhone Passwords' + ) + }) + + test.each([ + ['null factor', null], + ['undefined factor', undefined], + ['missing name', { friendly_name: undefined }], + ['empty name', { friendly_name: '' }], + ['whitespace-only name', { friendly_name: ' ' }], + ])('returns undefined for %s', (_label, factor) => { + expect(getFactorFriendlyName(factor)).toBeUndefined() + }) +}) + +describe('getFactorDisplayName', () => { + test('returns the friendly name when present', () => { + expect(getFactorDisplayName({ friendly_name: 'Work phone' })).toBe('Work phone') + }) + + test('falls back to a generic label when the name is blank', () => { + expect(getFactorDisplayName({ friendly_name: ' ' })).toBe('your authenticator app') + }) +}) + +describe('MFA_SUPPORT_EMAIL_HREF', () => { + test('targets support with an encoded subject', () => { + const url = new URL(MFA_SUPPORT_EMAIL_HREF) + + expect(url.protocol).toBe('mailto:') + expect(url.pathname).toBe('support@supabase.com') + expect(url.searchParams.get('subject')).toBe('Unable to sign in via MFA') + }) +}) diff --git a/apps/studio/components/interfaces/SignIn/SignInMfa.utils.ts b/apps/studio/components/interfaces/SignIn/SignInMfa.utils.ts new file mode 100644 index 00000000000..512db3a4917 --- /dev/null +++ b/apps/studio/components/interfaces/SignIn/SignInMfa.utils.ts @@ -0,0 +1,20 @@ +import type { Factor } from '@supabase/supabase-js' + +export const MFA_SUPPORT_EMAIL_HREF = `mailto:support@supabase.com?subject=${encodeURIComponent('Unable to sign in via MFA')}` + +type FactorWithName = Pick | null | undefined + +/** + * Returns the user-provided name of a TOTP factor, or `undefined` if it has none. + * + * The name is a free-text label chosen at enrollment time. It does not identify which + * authenticator app actually generates the codes. + */ +export function getFactorFriendlyName(factor: FactorWithName): string | undefined { + const name = factor?.friendly_name?.trim() + return name && name.length > 0 ? name : undefined +} + +export function getFactorDisplayName(factor: FactorWithName): string { + return getFactorFriendlyName(factor) ?? 'your authenticator app' +} diff --git a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx index 9c6e73dd10a..7e9da128c79 100644 --- a/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx +++ b/apps/studio/components/interfaces/SignIn/SignInMfaForm.tsx @@ -13,6 +13,11 @@ import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' import z from 'zod' +import { + getFactorDisplayName, + getFactorFriendlyName, + MFA_SUPPORT_EMAIL_HREF, +} from './SignInMfa.utils' import { AlertError } from '@/components/ui/AlertError' import { useAddLoginEvent } from '@/data/misc/audit-login-mutation' import { useMfaChallengeAndVerifyMutation } from '@/data/profile/mfa-challenge-and-verify-mutation' @@ -28,13 +33,6 @@ const schema = z.object({ const formId = 'sign-in-mfa-form' -const SUPPORT_EMAIL_HREF = `mailto:support@supabase.com?subject=${encodeURIComponent('Unable to sign in via MFA')}` - -function getFactorDisplayName(factor: Pick | null | undefined): string { - const name = factor?.friendly_name?.trim() - return name && name.length > 0 ? name : 'your authenticator app' -} - interface SignInMfaFormProps { context?: 'forgot-password' | 'sign-in' } @@ -120,6 +118,7 @@ export const SignInMfaForm = ({ context = 'sign-in' }: SignInMfaFormProps) => { }, [code]) const error = useAuthError() + const selectedFactorName = getFactorFriendlyName(selectedFactor) if (error) { return ( @@ -133,7 +132,7 @@ export const SignInMfaForm = ({ context = 'sign-in' }: SignInMfaFormProps) => { Back to sign in } @@ -169,15 +168,16 @@ export const SignInMfaForm = ({ context = 'sign-in' }: SignInMfaFormProps) => { render={({ field }) => ( - Code generated by{' '} - - {getFactorDisplayName(selectedFactor)} - + From the authenticator app registered as{' '} + {selectedFactorName} - ) : null + ) : ( + 'From the authenticator app registered to this account' + ) } > @@ -270,6 +270,14 @@ export const SignInMfaForm = ({ context = 'sign-in' }: SignInMfaFormProps) => { Force sign out and clear cookies +
  • + + Email support to regain access + +
  • diff --git a/apps/studio/components/interfaces/SignIn/SignInRecoveryCodeForm.tsx b/apps/studio/components/interfaces/SignIn/SignInRecoveryCodeForm.tsx index 0789b140f9a..f8b6949496f 100644 --- a/apps/studio/components/interfaces/SignIn/SignInRecoveryCodeForm.tsx +++ b/apps/studio/components/interfaces/SignIn/SignInRecoveryCodeForm.tsx @@ -23,6 +23,7 @@ import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout' import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' import z from 'zod' +import { MFA_SUPPORT_EMAIL_HREF } from './SignInMfa.utils' import { AlertError } from '@/components/ui/AlertError' import { useAddLoginEvent } from '@/data/misc/audit-login-mutation' import { useRecoveryCodesStatusQuery } from '@/data/recovery-codes/recovery-codes-status-query' @@ -37,8 +38,6 @@ const schema = z.object({ const formId = 'sign-in-recovery-code-form' -const SUPPORT_EMAIL_HREF = `mailto:support@supabase.com?subject=${encodeURIComponent('Unable to sign in via MFA')}` - export const SignInRecoveryCodeForm = () => { const router = useRouter() const signOut = useSignOut() @@ -112,7 +111,7 @@ export const SignInRecoveryCodeForm = () => { Back to sign in } @@ -238,6 +237,14 @@ export const SignInRecoveryCodeForm = () => { Force sign out and clear cookies +
  • + + Email support to regain access + +