diff --git a/dashboard-fresh/islands/LoginForm.tsx b/dashboard-fresh/islands/LoginForm.tsx index e8ae29d..fef41e5 100644 --- a/dashboard-fresh/islands/LoginForm.tsx +++ b/dashboard-fresh/islands/LoginForm.tsx @@ -258,9 +258,9 @@ export default function LoginForm({ language, initialEmail = '', onSuccess }: Lo if (onSuccess) { onSuccess() } else { - // Redirect to home after short delay + // Redirect to user panel after short delay setTimeout(() => { - globalThis.location.href = '/' + globalThis.location.href = '/panel' }, 1000) } } catch (submitError) { diff --git a/dashboard-fresh/islands/Navbar.tsx b/dashboard-fresh/islands/Navbar.tsx index db9d5e7..67d0f1f 100644 --- a/dashboard-fresh/islands/Navbar.tsx +++ b/dashboard-fresh/islands/Navbar.tsx @@ -34,6 +34,46 @@ export default function Navbar({ language, user, pathname = '/' }: NavbarProps) const searchValue = useSignal('') const navRef = useRef(null) + // Use provided user from server, but try to fetch fresh session on client + const currentUser = useSignal(user || null) + + // Fetch session on client-side to get fresh user info + useEffect(() => { + let isActive = true + + const fetchSession = async () => { + try { + const response = await fetch('/api/auth/session', { + credentials: 'include', + }) + + if (!isActive || !response.ok) { + return + } + + const data = (await response.json()) as { + user?: User + } + + if (isActive && data.user) { + currentUser.value = data.user + } + } catch (error) { + // Silently fail if session fetch fails + console.debug('Failed to fetch session:', error) + } + } + + // Only fetch on client side + if (typeof window !== 'undefined') { + fetchSession() + } + + return () => { + isActive = false + } + }, []) + const isHiddenRoute = pathname ? ['/login', '/register'].some((prefix) => pathname.startsWith(prefix)) : false // Generate language toggle URL that preserves current path and params @@ -190,7 +230,7 @@ export default function Navbar({ language, user, pathname = '/' }: NavbarProps) - + {/* Mail Icon */}
(menuOpen.value = false)}> - +