fix: email verification redirect and already-used token message
1. Use window.location.href instead of navigate() for reliable redirect 2. Improve backend error message for already-used verification tokens 3. Show user-friendly message when token was already verified 4. Reduce redirect delay from 2s to 1.5s for better UX Fixes: - Empty page after email verification - Generic error when clicking verification link twice Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1521c2f221
commit
1cd93d521e
|
|
@ -289,7 +289,9 @@ async def verify_email(token: str):
|
|||
prof = cur.fetchone()
|
||||
|
||||
if not prof:
|
||||
raise HTTPException(400, "Ungültiger Verifikations-Link")
|
||||
# Token not found - might be already used/verified
|
||||
# Check if there's a verified profile (token was deleted after verification)
|
||||
raise HTTPException(400, "Verifikations-Link ungültig oder bereits verwendet. Falls du bereits verifiziert bist, melde dich einfach an.")
|
||||
|
||||
if prof['email_verified']:
|
||||
raise HTTPException(400, "E-Mail-Adresse bereits bestätigt")
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ export default function Verify() {
|
|||
setAuthFromToken(result.token, result.profile)
|
||||
setStatus('success')
|
||||
|
||||
// Redirect to dashboard after 2 seconds
|
||||
// Redirect to dashboard after 1.5 seconds
|
||||
setTimeout(() => {
|
||||
navigate('/dashboard')
|
||||
}, 2000)
|
||||
window.location.href = '/'
|
||||
}, 1500)
|
||||
} else {
|
||||
setStatus('error')
|
||||
setError('Verifizierung erfolgreich, aber Login fehlgeschlagen')
|
||||
|
|
@ -44,11 +44,13 @@ export default function Verify() {
|
|||
} catch (err) {
|
||||
const errorMsg = err.message || 'Verifizierung fehlgeschlagen'
|
||||
|
||||
// Check if already verified
|
||||
if (errorMsg.includes('bereits bestätigt') || errorMsg.includes('already verified')) {
|
||||
// Check if already verified or already used
|
||||
if (errorMsg.includes('bereits bestätigt') || errorMsg.includes('already verified') ||
|
||||
errorMsg.includes('bereits verwendet') || errorMsg.includes('already used')) {
|
||||
setStatus('already_verified')
|
||||
setError(errorMsg) // Show the actual message
|
||||
// Auto-redirect to login after 3 seconds
|
||||
setTimeout(() => navigate('/login'), 3000)
|
||||
setTimeout(() => { window.location.href = '/login' }, 3000)
|
||||
}
|
||||
// Check if token expired
|
||||
else if (errorMsg.includes('abgelaufen') || errorMsg.includes('expired')) {
|
||||
|
|
@ -200,13 +202,19 @@ export default function Verify() {
|
|||
<h2 style={{marginBottom:12, color:'var(--accent-dark)'}}>
|
||||
E-Mail bereits bestätigt
|
||||
</h2>
|
||||
<p style={{color:'var(--text2)', lineHeight:1.6, marginBottom:24}}>
|
||||
Deine E-Mail-Adresse wurde bereits verifiziert.
|
||||
Du kannst dich jetzt anmelden.
|
||||
<p style={{color:'var(--text2)', lineHeight:1.6, marginBottom:error?12:24}}>
|
||||
{error || 'Deine E-Mail-Adresse wurde bereits verifiziert. Du kannst dich jetzt anmelden.'}
|
||||
</p>
|
||||
{!error && (
|
||||
<p style={{fontSize:13, color:'var(--text3)'}}>
|
||||
Du wirst gleich zum Login weitergeleitet...
|
||||
</p>
|
||||
)}
|
||||
{error && (
|
||||
<p style={{fontSize:13, color:'var(--text3)', marginTop:16}}>
|
||||
Du wirst gleich zum Login weitergeleitet...
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user