fix: prevent React StrictMode double execution in Verify
All checks were successful
Deploy Development / deploy (push) Successful in 56s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

Added hasVerified flag to prevent useEffect from running twice
in React 18 StrictMode (development mode).

This was causing:
1. First call: 200 OK - verification successful
2. Second call: 400 Bad Request - already verified
3. Error shown to user despite successful verification

The fix ensures verify() only runs once per component mount.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-21 11:38:03 +01:00
parent ca9112ebc0
commit e62b05c224

View File

@ -14,15 +14,17 @@ export default function Verify() {
const [email, setEmail] = useState('') const [email, setEmail] = useState('')
const [resending, setResending] = useState(false) const [resending, setResending] = useState(false)
const [resendSuccess, setResendSuccess] = useState(false) const [resendSuccess, setResendSuccess] = useState(false)
const [hasVerified, setHasVerified] = useState(false)
useEffect(() => { useEffect(() => {
if (hasVerified) return // Prevent React StrictMode double execution
if (!token) {
setStatus('error')
setError('Kein Verifikations-Token gefunden')
return
}
setHasVerified(true)
const verify = async () => { const verify = async () => {
if (!token) {
setStatus('error')
setError('Kein Verifikations-Token gefunden')
return
}
try { try {
const result = await api.verifyEmail(token) const result = await api.verifyEmail(token)