You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 67d3f24
Browse filesBrowse the repository at this point in the historyBrowse files
fix(auth): store and revoke refresh tokens so silent refresh works
/api/login and /api/register return a refresh_token, but the login and
register forms only kept the access token, so apiFetch's silent-refresh
path never had one to use and every session hard-expired at 72h. Pass
it through an AuthSession and store it at login; logout now revokes it
via POST /api/auth/logout before clearing both tokens.
Logout uses plain fetch rather than apiFetch on purpose: with an
expired access token, apiFetch would rotate the refresh token first and
logout would then revoke the old, already-dead one.
Storing the token exposed a backend bug the dead path had hidden:
/api/auth/refresh compared the TIMESTAMPTZ expires_at with a naive
utcnow(), raising TypeError, so every refresh returned 500. Use
timezone-aware UTC both when writing and checking expiry (the naive
write was also hours off on a database not running in UTC).
Also:
- treat a refresh token alone as a session on startup
- only log out on a real 401 at startup; a 5xx or network error now
keeps the tokens and shows a toast instead
- check r.ok before parsing /api/projects (new loadProjects helper),
so an error body no longer throws inside normalizeProjects
- update the walkthrough's "72 hours, no way to refresh" note
0 commit comments