Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/components/UserProfile/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ const UserProfile: FC<UserProfileProps> = ({
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 (
Expand Down
Loading