mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem Users need to fix missing or exhausted recovery codes without leaving the recovery reminder. ## Solution Add a reusable recovery reminder and full-screen modal shell using the existing recovery-code dialogs. Dismissal is a callback. The automatic layout gate in #51643 mounts the UI; there is no standalone preview route. | State | Screenshot | | --- | --- | | Blocked request | <img width="654" height="800" alt="39307" src="https://github.com/user-attachments/assets/2ba80ea7-24ad-4d29-ab50-730890501014" /> | | Recovery codes used up | <img width="654" height="800" alt="Supabase" src="https://github.com/user-attachments/assets/5dd63735-1254-4855-bbd8-04c2e4c699fa" /> | | No recovery codes | <img width="654" height="800" alt="Supabase" src="https://github.com/user-attachments/assets/58ff5b91-7da6-4c39-ad99-cea7cce8cf73" /> | | Recovery codes saved (just completed above _Generate codes_ step) | <img width="654" height="800" alt="63500" src="https://github.com/user-attachments/assets/1fc7ca56-a7cb-4edd-a3cd-4d8cf5c09659" /> | ## Review instructions **This PR’s own deploy preview cannot show the takeover.** Review its diff here, but test the assembled stack on [#51643’s staging preview](https://studio-staging-git-dnywh-account-recovery-interstitial-supabase.vercel.app/dashboard/organizations). The controller only mounts in #51643. Before each scenario: use a non-SSO staging test account with MFA verified; check `enableAccountRecoveryInterstitial` and `enableAuthRecoveryCodes` are both true in the staging dev toolbar, then close the toolbar and other dialogs. Clear `account-recovery-reminder:<userId>` from DevTools Application → Local Storage **for that preview origin**, then reload the dashboard. 1. **Exhausted codes:** use an account with existing codes and exactly one verified authenticator. In DevTools Network, right-click GET `/factors/recovery-codes` → **Override content**. Keep the JSON fields, set `remaining` to `0`, save and reload. Confirm the request shows the overridden response and the takeover opens. 2. **Missing codes, separate scenario:** disable overrides and use an MFA test account with no generated codes. Clear snooze and reload. Setting `remaining` to `0` simulates exhausted codes, not missing codes. 3. Disable overrides before live actions. Cancel regeneration to check existing codes remain intact, then generate or regenerate codes and acknowledge storage. These actions change the test account. Continue or Skip should reveal the unchanged URL and page.
10 lines
440 B
TypeScript
10 lines
440 B
TypeScript
import type { AccountRecoveryFinding } from '@/lib/account-recovery/evaluate-account-recovery'
|
|
|
|
export type RecoveryGap = 'missing' | 'exhausted'
|
|
|
|
export function getRecoveryGap(findings: AccountRecoveryFinding[]): RecoveryGap | null {
|
|
if (findings.some((finding) => finding.id === 'recovery-codes-exhausted')) return 'exhausted'
|
|
if (findings.some((finding) => finding.id === 'recovery-codes-missing')) return 'missing'
|
|
return null
|
|
}
|