Fix TOTP setup component

This commit is contained in:
gpt-engineer-app[bot]
2025-10-01 15:00:22 +00:00
parent f9cdba84fe
commit d6efa2d39f

View File

@@ -94,13 +94,21 @@ export function TOTPSetup() {
setLoading(true); setLoading(true);
try { try {
const { error } = await supabase.auth.mfa.verify({ // Step 1: Create a challenge first
const { data: challengeData, error: challengeError } = await supabase.auth.mfa.challenge({
factorId
});
if (challengeError) throw challengeError;
// Step 2: Verify using the challengeId from the challenge response
const { error: verifyError } = await supabase.auth.mfa.verify({
factorId, factorId,
challengeId: factorId, // For enrollment, challengeId is the same as factorId challengeId: challengeData.id,
code: verificationCode.trim() code: verificationCode.trim()
}); });
if (error) throw error; if (verifyError) throw verifyError;
toast({ toast({
title: 'TOTP Enabled', title: 'TOTP Enabled',