Files
supabase/apps/studio/lib/account-recovery/single-oauth-identity.test.ts
Danny White 5cf3cf1032 feat(studio): make security the home for sign-in and recovery setup (#52358)
## Problem

- Sign-in methods are in Preferences, separate from MFA and recovery
settings.
- The risk of a single sign-in method (e.g. GitHub, and getting locked
out of that account) isn’t clearly communicated.

## Solution

- Bring sign-in methods, MFA and recovery codes together on the Security
page. If Security is disabled, sign-in methods remain accessible in
Preferences.
- Highlight the most important next step with a primary button. For
example, when MFA is off, “Set up MFA” takes priority over adding a
password.
- Explain the risk of relying on a single sign-in provider, and make it
clear which email address a new password will apply to.
- After connecting a sign-in provider, return users to the settings page
they can access. Links to password setup open the password dialog
directly.

| After |
| --- |
| <img width="1460" height="1426" alt="CleanShot 2026-11-06 at 14 54
23@2x"
src="https://github.com/user-attachments/assets/afb82601-1b6f-43be-9e98-a0edb8d529c8"
/> |
| _The “Sign-in methods” section moved to Account → Security. Note also
the new Admonition regarding the risk of a single (GitHub) sign-in
method._ |

## Review instructions

1. Open
[Security](https://studio-staging-git-dnywh-recovery-security-home-supabase.vercel.app/dashboard/account/security#sign-in-methods).
Check sign-in methods appear above MFA and recovery codes. With MFA off,
“Set up MFA” should be primary.
2. Open Preferences. Sign-in methods should be absent unless Security is
disabled.
3. On a test account, check password setup, email editing and provider
linking. [Open password setup
directly](https://studio-staging-git-dnywh-recovery-security-home-supabase.vercel.app/dashboard/account/security?securityAction=set-password#sign-in-methods),
then cancel and confirm it stays closed.
2026-11-09 17:42:43 +11:00

29 lines
977 B
TypeScript

import { describe, expect, it } from 'vitest'
import { isSingleOAuthIdentity } from './single-oauth-identity'
const email = 'person@example.com'
describe('isSingleOAuthIdentity', () => {
it('is true for a lone OAuth provider with an email', () => {
expect(isSingleOAuthIdentity({ identities: [{ provider: 'github' }], email })).toBe(true)
})
it.each(['email', 'phone', 'sso:4d21b3cf-3a2f-44d3-b7d6-2b0dd393f671'])(
'is false for a lone %s identity',
(provider) => {
expect(isSingleOAuthIdentity({ identities: [{ provider }], email })).toBe(false)
}
)
it('is false with several identities or no email', () => {
expect(
isSingleOAuthIdentity({ identities: [{ provider: 'github' }, { provider: 'google' }], email })
).toBe(false)
expect(isSingleOAuthIdentity({ identities: [{ provider: 'github' }], email: undefined })).toBe(
false
)
expect(isSingleOAuthIdentity({ identities: [], email })).toBe(false)
})
})