From 0f7e644f17237338d8f60ee415bfce599085ef34 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Sun, 8 Feb 2026 21:21:59 +0100 Subject: [PATCH] fix: fetch full profile after login so header shows display name without refresh Co-authored-by: Cursor --- lib/auth/context.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/auth/context.tsx b/lib/auth/context.tsx index bf4bcd4..0a8245f 100644 --- a/lib/auth/context.tsx +++ b/lib/auth/context.tsx @@ -53,6 +53,20 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { localStorage.setItem('user', JSON.stringify(userData)) setUser(userData) router.refresh() + // * Fetch full profile (including display_name) so header shows correct name without page refresh + apiRequest('/auth/user/me') + .then((fullProfile) => { + setUser((prev) => { + const merged = { + ...fullProfile, + org_id: prev?.org_id ?? fullProfile.org_id, + role: prev?.role ?? fullProfile.role, + } + localStorage.setItem('user', JSON.stringify(merged)) + return merged + }) + }) + .catch((e) => console.error('Failed to fetch full profile after login', e)) } const logout = useCallback(async () => {