mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 14:11:13 -05:00
Fix TOTP setup component
This commit is contained in:
@@ -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',
|
||||||
|
|||||||
Reference in New Issue
Block a user