mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem Studio tracks completion of recovery setup, but there are no events for copying or downloading the codes. ## Solution Track both actions in the shared recovery-code dialog. Record a copy after the clipboard write succeeds and a download when the browser starts it. The events carry no recovery-code values. ## Review instructions 1. Open [Recovery codes](https://supabase.com/dashboard/account/security#recovery-codes) on this branch's Studio preview with a disposable MFA account. Select **Generate recovery codes** or **Regenerate** if it already has a set. 2. In **Save your recovery codes**, select **Copy**, then **Download**. Check the browser network panel for `recovery_codes_copied` and `recovery_codes_download_clicked` in the telemetry requests (`telemetry/event`).
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { useState } from 'react'
|
|
import { Button } from 'ui'
|
|
|
|
import { AddNewFactorModal } from '../TOTPFactors/AddNewFactorModal'
|
|
import { RecoveryTaskRow } from './RecoveryTaskRow'
|
|
|
|
export const AuthenticatorTask = ({
|
|
onStart,
|
|
onComplete,
|
|
onRecoveryCodesSaved,
|
|
}: {
|
|
onStart: () => void
|
|
onComplete?: () => void
|
|
onRecoveryCodesSaved: () => void
|
|
}) => {
|
|
const [isOpen, setIsOpen] = useState(false)
|
|
const [isComplete, setIsComplete] = useState(false)
|
|
const handleComplete = () => {
|
|
setIsComplete(true)
|
|
onComplete?.()
|
|
}
|
|
const handleClose = () => setIsOpen(false)
|
|
|
|
return (
|
|
<>
|
|
<RecoveryTaskRow
|
|
title={isComplete ? 'Backup MFA method added' : 'Only one MFA method'}
|
|
description={
|
|
isComplete
|
|
? 'Another MFA method is verified for your account.'
|
|
: 'Set up an authenticator app on another device as a backup.'
|
|
}
|
|
isComplete={isComplete}
|
|
>
|
|
{!isComplete && (
|
|
<Button
|
|
variant="default"
|
|
size="tiny"
|
|
onClick={() => {
|
|
onStart()
|
|
setIsOpen(true)
|
|
}}
|
|
>
|
|
Add backup
|
|
</Button>
|
|
)}
|
|
</RecoveryTaskRow>
|
|
<AddNewFactorModal
|
|
visible={isOpen}
|
|
recoveryCodesSurface="recovery_interstitial"
|
|
onClose={handleClose}
|
|
onComplete={handleComplete}
|
|
onRecoveryCodesSaved={onRecoveryCodesSaved}
|
|
/>
|
|
</>
|
|
)
|
|
}
|