import { useState } from 'react' import { Check, ArrowLeft } from 'lucide-react' export function ForgotPassword({ onBack }) { const [email, setEmail] = useState('') const [sent, setSent] = useState(false) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const handleSubmit = async () => { if (!email.trim()) return setError('E-Mail eingeben') setLoading(true); setError(null) try { const r = await fetch('/api/auth/forgot-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email.trim() }) }) if (!r.ok) throw new Error(await r.text()) setSent(true) } catch(e) { setError(e.message) } finally { setLoading(false) } } if (sent) return (
📧
E-Mail gesendet
Falls ein Konto mit dieser E-Mail existiert, hast du einen Link zum ZurĂźcksetzen erhalten. Bitte prĂźfe auch deinen Spam-Ordner.
) return (
Passwort vergessen
Recovery-Link per E-Mail
Gib deine E-Mail-Adresse ein. Du erhältst einen Link zum Zurßcksetzen deines Passworts.
setEmail(e.target.value)} onKeyDown={e=>e.key==='Enter'&&handleSubmit()} style={{width:'100%',marginBottom:12,boxSizing:'border-box'}} autoFocus/> {error &&
{error}
}
) } export function ResetPassword({ token, onDone }) { const [pin, setPin] = useState('') const [pin2, setPin2] = useState('') const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const [done, setDone] = useState(false) const handleReset = async () => { if (pin.length < 4) return setError('Mind. 4 Zeichen') if (pin !== pin2) return setError('Eingaben stimmen nicht Ăźberein') setLoading(true); setError(null) try { const r = await fetch('/api/auth/reset-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token, pin }) }) if (!r.ok) { const err = await r.json() throw new Error(err.detail || 'Fehler') } setDone(true) } catch(e) { setError(e.message) } finally { setLoading(false) } } if (done) return (
✅
Passwort geändert
Du kannst dich jetzt mit deinem neuen Passwort einloggen.
) return (
Neues Passwort setzen
Wähle ein neues Passwort oder eine neue PIN (mind. 4 Zeichen).
setPin(e.target.value)} style={{width:'100%',marginBottom:10,boxSizing:'border-box'}} autoFocus/> setPin2(e.target.value)} onKeyDown={e=>e.key==='Enter'&&handleReset()} style={{width:'100%',marginBottom:12,boxSizing:'border-box'}}/> {error &&
{error}
}
) }