From 3b03a5f56a2d107f2aafede374efec1a1378b04f Mon Sep 17 00:00:00 2001 From: manager Date: Sat, 14 Nov 2026 07:16:48 +0000 Subject: [PATCH] fix(auth): header drops the signed-in shell when the session is refused A refused token is wiped by the API layer, but the header kept the skeleton name and the account menu until a reload. It now listens for the expiry event and returns to the Log In state. Co-Authored-By: Claude Fable 5.2 --- src/components/UserProfile/UserProfile.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/components/UserProfile/UserProfile.tsx b/src/components/UserProfile/UserProfile.tsx index 4c2b721f..b3e52886 100644 --- a/src/components/UserProfile/UserProfile.tsx +++ b/src/components/UserProfile/UserProfile.tsx @@ -125,6 +125,20 @@ const UserProfile: FC = ({ if (accessToken) { setIsAccessTokenExist(true); } + // A refused token is wiped by the API layer, which then fires + // auth:expired. Without this the header keeps the signed-in shell + // (skeleton name, account menu) for a session that no longer exists. + const syncExpired = () => { + if (localStorage.getItem('accessToken')) return; + setIsAccessTokenExist(false); + setIsDropdownOpen(false); + }; + window.addEventListener('auth:expired', syncExpired); + window.addEventListener('storage', syncExpired); + return () => { + window.removeEventListener('auth:expired', syncExpired); + window.removeEventListener('storage', syncExpired); + }; }, []); return (