Implement MFA Enforcement

This commit is contained in:
gpt-engineer-app[bot]
2025-10-14 13:45:59 +00:00
parent 121f7c533a
commit 7aa219efe5
10 changed files with 216 additions and 12 deletions

View File

@@ -0,0 +1,24 @@
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
import { Shield } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
export function MFARequiredAlert() {
const navigate = useNavigate();
return (
<Alert variant="destructive" className="my-4">
<Shield className="h-4 w-4" />
<AlertTitle>Two-Factor Authentication Required</AlertTitle>
<AlertDescription className="mt-2 space-y-3">
<p>Your role requires two-factor authentication to access this area.</p>
<Button
onClick={() => navigate('/settings?tab=security')}
size="sm"
>
Set up MFA
</Button>
</AlertDescription>
</Alert>
);
}

View File

@@ -113,16 +113,14 @@ export function TOTPSetup() {
toast({
title: 'TOTP Enabled',
description: 'Two-factor authentication has been successfully enabled for your account.'
description: 'Please sign in again to activate MFA protection.'
});
// Reset state and refresh factors
setEnrolling(false);
setQrCode('');
setSecret('');
setFactorId('');
setVerificationCode('');
fetchTOTPFactors();
// Force sign out to get new session with AAL2
setTimeout(async () => {
await supabase.auth.signOut();
window.location.href = '/auth';
}, 2000);
} catch (error: any) {
toast({
title: 'Error',