mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 06:51:13 -05:00
Continue console cleanup
This commit is contained in:
@@ -16,6 +16,8 @@ import { MFAChallenge } from './MFAChallenge';
|
||||
import { verifyMfaUpgrade } from '@/lib/authService';
|
||||
import { setAuthMethod } from '@/lib/sessionFlags';
|
||||
import { validateEmailNotDisposable } from '@/lib/emailValidation';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
interface AuthModalProps {
|
||||
open: boolean;
|
||||
@@ -241,7 +243,7 @@ export function AuthModal({ open, onOpenChange, defaultTab = 'signin' }: AuthMod
|
||||
username: formData.username,
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('Failed to register Novu subscriber:', err);
|
||||
logger.error('Failed to register Novu subscriber', { error: getErrorMessage(err) });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
|
||||
import { toast } from 'sonner';
|
||||
import { getSessionAAL } from '@/types/supabase-session';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useRequireMFA } from '@/hooks/useRequireMFA';
|
||||
import {
|
||||
@@ -30,6 +29,7 @@ interface MFARemovalDialogProps {
|
||||
|
||||
export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MFARemovalDialogProps) {
|
||||
const { requiresMFA } = useRequireMFA();
|
||||
const { toast } = useToast();
|
||||
const [step, setStep] = useState<'password' | 'totp' | 'confirm'>('password');
|
||||
const [password, setPassword] = useState('');
|
||||
const [totpCode, setTotpCode] = useState('');
|
||||
@@ -43,7 +43,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
const currentAal = getSessionAAL(session);
|
||||
|
||||
if (currentAal !== 'aal2') {
|
||||
toast.error('Please verify your identity with MFA before making security changes');
|
||||
toast({
|
||||
title: 'MFA Required',
|
||||
description: 'Please verify your identity with MFA before making security changes',
|
||||
variant: 'destructive'
|
||||
});
|
||||
onOpenChange(false);
|
||||
}
|
||||
};
|
||||
@@ -62,7 +66,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
|
||||
const handlePasswordVerification = async () => {
|
||||
if (!password.trim()) {
|
||||
toast.error('Please enter your password');
|
||||
toast({
|
||||
title: 'Password Required',
|
||||
description: 'Please enter your password',
|
||||
variant: 'destructive'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,10 +88,12 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
toast.success('Password verified');
|
||||
toast({
|
||||
title: 'Password Verified',
|
||||
description: 'Password verified successfully'
|
||||
});
|
||||
setStep('totp');
|
||||
} catch (error: unknown) {
|
||||
console.error('Password verification failed:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -92,7 +102,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
|
||||
const handleTOTPVerification = async () => {
|
||||
if (!totpCode.trim() || totpCode.length !== 6) {
|
||||
toast.error('Please enter a valid 6-digit code');
|
||||
toast({
|
||||
title: 'Invalid Code',
|
||||
description: 'Please enter a valid 6-digit code',
|
||||
variant: 'destructive'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,10 +136,12 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
throw new Error('Session must be at AAL2 to remove MFA');
|
||||
}
|
||||
|
||||
toast.success('TOTP code verified');
|
||||
toast({
|
||||
title: 'Code Verified',
|
||||
description: 'TOTP code verified successfully'
|
||||
});
|
||||
setStep('confirm');
|
||||
} catch (error: unknown) {
|
||||
console.error('TOTP verification failed:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -135,7 +151,11 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
const handleMFARemoval = async () => {
|
||||
// Phase 2: Check if user's role requires MFA
|
||||
if (requiresMFA) {
|
||||
toast.error('Your role requires two-factor authentication and it cannot be disabled');
|
||||
toast({
|
||||
title: 'MFA Required',
|
||||
description: 'Your role requires two-factor authentication and it cannot be disabled',
|
||||
variant: 'destructive'
|
||||
});
|
||||
handleClose();
|
||||
return;
|
||||
}
|
||||
@@ -152,11 +172,13 @@ export function MFARemovalDialog({ open, onOpenChange, factorId, onSuccess }: MF
|
||||
if (error) throw error;
|
||||
if (data?.error) throw new Error(data.error);
|
||||
|
||||
toast.success('Two-factor authentication has been disabled');
|
||||
toast({
|
||||
title: 'MFA Disabled',
|
||||
description: 'Two-factor authentication has been disabled'
|
||||
});
|
||||
handleClose();
|
||||
onSuccess();
|
||||
} catch (error: unknown) {
|
||||
console.error('MFA removal failed:', error);
|
||||
toast.error(getErrorMessage(error));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user