From 3dc3774d766fea3fe55087765b2323d68b51413a Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 21 Mar 2026 12:35:04 +0100 Subject: [PATCH] fix: parse JSON error messages and redirect to dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Parse JSON error responses to extract 'detail' field Fixes: {"detail":"..."} shown as raw JSON instead of clean text 2. Redirect 'already_verified' to '/' instead of '/login' Fixes: Users land on empty page when already logged in 3. Change button text: "Jetzt anmelden" → "Weiter zum Dashboard" Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/Verify.jsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/Verify.jsx b/frontend/src/pages/Verify.jsx index 111a3c6..29275b9 100644 --- a/frontend/src/pages/Verify.jsx +++ b/frontend/src/pages/Verify.jsx @@ -42,15 +42,23 @@ export default function Verify() { setError('Verifizierung erfolgreich, aber Login fehlgeschlagen') } } catch (err) { - const errorMsg = err.message || 'Verifizierung fehlgeschlagen' + let errorMsg = err.message || 'Verifizierung fehlgeschlagen' + + // Try to parse JSON error response + try { + const parsed = JSON.parse(errorMsg) + if (parsed.detail) errorMsg = parsed.detail + } catch (e) { + // Not JSON, use as-is + } // 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(() => { window.location.href = '/login' }, 3000) + // Auto-redirect to dashboard after 3 seconds (let App.jsx decide login vs dashboard) + setTimeout(() => { window.location.href = '/' }, 3000) } // Check if token expired else if (errorMsg.includes('abgelaufen') || errorMsg.includes('expired')) { @@ -218,10 +226,10 @@ export default function Verify() { )