/** * TwoFactorVerify - التحقق من رمز 2FA عند تسجيل الدخول */ import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Alert, AlertDescription } from '@/components/ui/alert'; import { Shield, Loader2 } from 'lucide-react'; interface TwoFactorVerifyProps { onSuccess: () => void; onCancel?: () => void; } const TwoFactorVerify: React.FC = ({ onSuccess, onCancel }) => { const [code, setCode] = useState(''); const [isVerifying, setIsVerifying] = useState(false); const [error, setError] = useState(null); const handleVerify = async () => { setError(null); if (!code || code.length !== 6 || !/^\d{6}$/.test(code)) { setError('أدخل رمز التحقق المكون من 6 أرقام'); return; } setIsVerifying(true); await new Promise(r => setTimeout(r, 800)); // في الإنتاج: إرسال الرمز للخادم للتحقق if (/^\d{6}$/.test(code)) { onSuccess(); } else { setError('الرمز غير صحيح. يرجى المحاولة مجدداً.'); } setIsVerifying(false); }; return (

التحقق بخطوتين

أدخل الرمز المكون من 6 أرقام من تطبيق Google Authenticator أو Authy

{ const val = e.target.value.replace(/\D/g, ''); setCode(val); setError(null); }} className="text-center text-3xl font-mono tracking-[0.5em] h-16 border-primary/30" dir="ltr" autoFocus /> {error && ( {error} )} {onCancel && ( )}

الرمز يتجدد كل 30 ثانية

); }; export default TwoFactorVerify;