diff --git a/frontend/src/context/AuthContext.jsx b/frontend/src/context/AuthContext.jsx index ece4633..1bcd76a 100644 --- a/frontend/src/context/AuthContext.jsx +++ b/frontend/src/context/AuthContext.jsx @@ -86,6 +86,18 @@ export function AuthProvider({ children }) { return data } + const setAuthFromToken = (token, profile) => { + // Direct token/profile set (for email verification auto-login) + localStorage.setItem(TOKEN_KEY, token) + localStorage.setItem(PROFILE_KEY, profile.id) + setSession({ + token, + profile_id: profile.id, + role: profile.role || 'user', + profile + }) + } + const logout = async () => { const token = localStorage.getItem(TOKEN_KEY) if (token) { @@ -102,7 +114,7 @@ export function AuthProvider({ children }) { return ( navigate('/login'), 3000) + } // Check if token expired - if (errorMsg.includes('abgelaufen') || errorMsg.includes('expired')) { + else if (errorMsg.includes('abgelaufen') || errorMsg.includes('expired')) { setStatus('expired') setError(errorMsg) } else { @@ -54,7 +60,7 @@ export default function Verify() { } verify() - }, [token, login, navigate]) + }, [token, setAuthFromToken, navigate]) const handleResend = async () => { if (!email.trim()) { @@ -177,6 +183,40 @@ export default function Verify() { ) } + if (status === 'already_verified') { + return ( +
+
+
+

+ E-Mail bereits bestätigt +

+

+ Deine E-Mail-Adresse wurde bereits verifiziert. + Du kannst dich jetzt anmelden. +

+

+ Du wirst gleich zum Login weitergeleitet... +

+
+ + +
+ ) + } + if (status === 'error') { return (