fix: email verification auto-login and user experience
Deploy Development / deploy (push) Successful in 37s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

AuthContext:
- Added setAuthFromToken() for direct token/profile set
- Used for email verification auto-login (no /login request)
- Properly initializes session with token and profile

Verify.jsx:
- Fixed auto-login: now uses setAuthFromToken() instead of login()
- Added "already_verified" status for better UX
- Auto-redirect to /login after 3s if already verified
- Shows friendly message instead of error

This fixes:
- 422 Unprocessable Entity error during auto-login
- Empty dashboard page after verification (now redirects correctly)
- "Ungültiger Link" error on second click (now shows "bereits bestätigt")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 4.6 committed 2026-03-21 10:32:24 +01:00
1 parent f843d71d6b
commit ca9112ebc0
2 files changed
+59 -7

No files matched your search

+13 -1
View File
@@ -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 (
<AuthContext.Provider value={{
session, loading, needsSetup,
login, setup, logout,
login, setup, logout, setAuthFromToken,
isAdmin, canUseAI, canExport,
token: session?.token,
profileId: session?.profile_id,