fix: email verification auto-login and user experience
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:
1 parent
f843d71d6b
commit
ca9112ebc0
2 files changed
+59
-7
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user