memos/web/src
Steven 9ecd7b876b fix(web): fix spurious logout on page reload with expired access token
Two bugs caused users to be redirected to /auth too frequently:

1. Race condition in Promise.all([initInstance(), initAuth()]):
   initInstance() makes a gRPC request whose auth interceptor calls
   getAccessToken() synchronously. When the access token was expired,
   getAccessToken() eagerly deleted it from localStorage as a "cleanup"
   side-effect. By the time initAuth() ran and checked hasStoredToken(),
   localStorage was already empty, so it skipped the getCurrentUser()
   call and the token refresh cycle entirely — logging the user out even
   when the refresh-token cookie was still valid. Fix: remove the
   localStorage deletion from getAccessToken(); clearAccessToken()
   (called on confirmed auth failure and logout) handles proper cleanup.

2. React Query retry: 1 caused a second refresh+redirect attempt after
   auth failures. The auth interceptor already handles token refresh and
   request retry internally. If it still throws Unauthenticated, the
   redirect is already in flight — a React Query retry only fires another
   failed refresh and a redundant redirectOnAuthFailure() call. Fix: use
   a shouldRetry function that skips retries for Unauthenticated errors
   while keeping the existing once-retry behaviour for other errors.
2026-02-23 14:08:59 +08:00
..
components fix(web): fix explore page showing private tags and improve stats hook 2026-02-23 13:15:01 +08:00
contexts fix(web): persist auth token in localStorage for cross-tab sessions 2026-02-22 13:55:46 +08:00
helpers feat: react query migration (#5379) 2025-12-24 22:59:18 +08:00
hooks fix(web): fix explore page showing private tags and improve stats hook 2026-02-23 13:15:01 +08:00
layouts fix(web): fix explore page showing private tags and improve stats hook 2026-02-23 13:15:01 +08:00
lib fix(web): fix spurious logout on page reload with expired access token 2026-02-23 14:08:59 +08:00
locales fix(web): improve MemoEditor layout and timestamp popover styling 2026-02-23 10:20:00 +08:00
pages fix(auth): make PKCE optional for OAuth sign-in (#5570) 2026-02-02 23:28:21 +08:00
router chore: simplify page loading logic 2026-01-27 23:37:32 +08:00
themes chore: polish dark styles 2026-01-26 21:59:36 +08:00
types feat: update instance profile to use admin user instead of initialized flag 2026-01-28 23:27:53 +08:00
utils fix: allow ampersand in tags to support compound tags 2026-02-11 22:55:45 +08:00
App.tsx fix(web): persist auth token in localStorage for cross-tab sessions 2026-02-22 13:55:46 +08:00
auth-state.ts fix(web): fix spurious logout on page reload with expired access token 2026-02-23 14:08:59 +08:00
connect.ts fix(web): redirect to auth page instead of explore on session expiry 2026-02-10 21:15:44 +08:00
i18n.ts refactor: remove MemoContentContext and integrate MemoViewContext 2025-12-28 12:46:12 +08:00
index.css feat: implement markdown components for enhanced rendering 2026-01-23 09:04:42 +08:00
instance-config.ts feat: react query migration (#5379) 2025-12-24 22:59:18 +08:00
main.tsx fix: prevent 401 errors on window focus when token expires 2026-02-05 22:14:48 +08:00