Skip to content

Fix access token not persisting on hard reload - #11

Open
MuhammadSadiqAli-EQ wants to merge 10 commits into
ibadia:mainfrom
MuhammadSadiqAli-EQ:add-login-signup-healthcheck-pages
Open

Fix access token not persisting on hard reload#11
MuhammadSadiqAli-EQ wants to merge 10 commits into
ibadia:mainfrom
MuhammadSadiqAli-EQ:add-login-signup-healthcheck-pages

Conversation

@MuhammadSadiqAli-EQ

Copy link
Copy Markdown
Contributor

Problem

Hard reload was logging the user out even when refresh token cookie was still valid. In-memory access token gets wiped on reload, but the code never tried the refresh token as fallback.

Fix

  • Added getValidAccessToken() in lib/auth.ts, checks memory first, falls back to refreshAccessToken() if empty
  • Added ProtectedLayout (loader-based route guard) for the new /auth page, redirects to /login if no valid token found

Testing

  • Confirmed /auth redirects to /login when no refresh cookie present (tested by manually deleting it from web devtool)
  • Confirmed hard reload on /auth keeps user logged in when refresh cookie is valid
  • Confirmed manually deleting memoryRefreshToken cookie triggers redirect correctly

Fixes #8

MuhammadSadiqAli-EQ and others added 10 commits July 27, 2026 20:52
- Add LoginForm, SignupForm, HealthCheck components
- Add CenteredPageLayout and TextField reusable UI
- Add lib/api.ts, auth.ts, config.ts, health.ts, types.ts
- Use clientAction for login/signup, clientLoader for health check
- Update routes to use React Router data APIs
Removed docstring explaining public access for HealthCheckAPI and simplified response structure.
Refactor authentication views to remove AuthenticationService calls and directly handle user authentication and password management. Update token handling and response structure for login and signup endpoints.
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.

frontend: Session storage fix for auth make sure that cookie base auth is working correctly

2 participants