feat: resend verification email functionality
Backend: - Added POST /api/auth/resend-verification endpoint - Rate limited to 3/hour to prevent abuse - Generates new verification token (24h validity) - Sends new verification email Frontend: - Verify.jsx: Added "expired" status with resend flow - Email input + "Neue Bestätigungs-E-Mail senden" button - EmailVerificationBanner: Added "Neue E-Mail senden" button - Shows success/error feedback inline - api.js: Added resendVerification() helper User flows: 1. Expired token → Verify page shows resend form 2. Email lost → Dashboard banner has resend button 3. Both flows use same backend endpoint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
9fb6e27256
commit
f843d71d6b
4 files changed
+263
-6
No files matched your search
@@ -1,7 +1,33 @@
|
||||
import { useState } from 'react'
|
||||
import { api } from '../utils/api'
|
||||
|
||||
export default function EmailVerificationBanner({ profile }) {
|
||||
const [resending, setResending] = useState(false)
|
||||
const [success, setSuccess] = useState(false)
|
||||
const [error, setError] = useState(null)
|
||||
|
||||
// Only show if email is not verified
|
||||
if (!profile || profile.email_verified !== false) return null
|
||||
|
||||
const handleResend = async () => {
|
||||
if (!profile.email) return
|
||||
|
||||
setResending(true)
|
||||
setError(null)
|
||||
setSuccess(false)
|
||||
|
||||
try {
|
||||
await api.resendVerification(profile.email)
|
||||
setSuccess(true)
|
||||
setTimeout(() => setSuccess(false), 5000)
|
||||
} catch (err) {
|
||||
setError(err.message || 'Fehler beim Versenden')
|
||||
setTimeout(() => setError(null), 5000)
|
||||
} finally {
|
||||
setResending(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
background: '#FFF4E6',
|
||||
@@ -11,7 +37,8 @@ export default function EmailVerificationBanner({ profile }) {
|
||||
marginBottom: 20,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 16
|
||||
gap: 16,
|
||||
flexWrap: 'wrap'
|
||||
}}>
|
||||
<div style={{
|
||||
fontSize: 32,
|
||||
@@ -19,7 +46,7 @@ export default function EmailVerificationBanner({ profile }) {
|
||||
}}>
|
||||
📧
|
||||
</div>
|
||||
<div style={{flex: 1}}>
|
||||
<div style={{flex: 1, minWidth: 200}}>
|
||||
<div style={{
|
||||
fontWeight: 700,
|
||||
fontSize: 15,
|
||||
@@ -34,9 +61,36 @@ export default function EmailVerificationBanner({ profile }) {
|
||||
lineHeight: 1.4
|
||||
}}>
|
||||
Bitte prüfe dein Postfach und klicke auf den Bestätigungslink.
|
||||
Ohne Bestätigung ist dein Account eingeschränkt.
|
||||
{success && (
|
||||
<span style={{color:'var(--accent)', fontWeight:600, marginLeft:4}}>
|
||||
✓ Neue E-Mail versendet!
|
||||
</span>
|
||||
)}
|
||||
{error && (
|
||||
<span style={{color:'var(--danger)', fontWeight:600, marginLeft:4}}>
|
||||
✗ {error}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleResend}
|
||||
disabled={resending || success}
|
||||
style={{
|
||||
padding: '8px 16px',
|
||||
borderRadius: 8,
|
||||
background: success ? 'var(--accent)' : '#F59E0B',
|
||||
color: 'white',
|
||||
fontWeight: 600,
|
||||
fontSize: 13,
|
||||
border: 'none',
|
||||
cursor: resending || success ? 'not-allowed' : 'pointer',
|
||||
whiteSpace: 'nowrap',
|
||||
opacity: resending || success ? 0.6 : 1
|
||||
}}
|
||||
>
|
||||
{resending ? 'Sende...' : success ? '✓ Versendet' : 'Neue E-Mail senden'}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user