Skip to content

fix(auth): header drops the signed-in shell when the session is refused - #261

Merged
manager merged 1 commit into
mainfrom
fix/header-expired-session
Nov 14, 2026
Merged

manager merged 1 commit into
mainfrom
fix/header-expired-session

Conversation

@manager

@manager manager commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

A refused sign-in token is wiped by the API layer, but the header kept the skeleton name and the account menu until a reload. The header now listens for the expiry event and returns to the Log In state.

Authorized by Wolf on 2026-11-14.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Claude finished @manager's task in 18s —— View job


Review of #261: header drops the signed-in shell on refused session

  • Read the diff and the call sites that dispatch auth:expired

Verdict: looks good, no blocking issues.

What I checked

  • Every dispatcher (src/api/strapi.ts:19, src/api/auth.ts:21, src/lib/library/axios/index.ts:39) removes accessToken from localStorage before firing auth:expired. So the localStorage.getItem('accessToken') guard in syncExpired reads the already-wiped state and the handler does what it says.
  • The listeners are added inside useEffect, so there is no SSR/hydration risk. Cleanup removes both listeners with the same function reference, so there is no leak or stale closure. The handler only calls state setters.
  • No convention violations: no new libraries, no inline styles, no import changes, no UX Core data touched.

Minor notes (non-blocking)

  1. The storage listener is one-directional. It logs this tab out when another tab wipes the token, but it never sets isAccessTokenExist back to true when another tab signs in. That is probably fine, since a sign-in usually reloads or redirects. If you want the two tabs symmetric, make the handler set the state from !!localStorage.getItem('accessToken'). The cost is dropping the early return and the dropdown close on the true branch.
  2. logout() in auth.ts also fires auth:expired, so this handler now runs on a user-initiated logout too. That is harmless, because the state ends up the same, but the comment says it is only for refused tokens. You could mention logout there.
  3. This is the second useEffect with an empty dependency array that reads accessToken (the effect at lines 123-142). Folding the link effect at lines 106-108 into one would tidy the file, but that is optional and outside this PR's scope.
  4. No Playwright coverage for this path. If you add one, the scenario is: seed a bad accessToken, let /users/me return 401, and assert the header shows Log In.

Nothing was run: this was a read-only review, and I did not install dependencies or run the linter or tests.

@manager
manager merged commit 244c826 into main Nov 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant