Skip to content

fix(web): keep the session on auth 401s and pin the API tests - #888

Merged
BaaRai merged 3 commits into
mainfrom
fix/web-auth-401-followup
Dec 3, 2026
Merged

BaaRai merged 3 commits into
mainfrom
fix/web-auth-401-followup

Conversation

@BaaRai

@BaaRai BaaRai commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #883.

  • apiFetch only treats a 401 from /auth/login as bad credentials. Every other 401 clears the session and returns to /login.
  • POST /api/auth/change-password returns 403 for a wrong current password and keeps 401 for an invalid or expired session, so a typo does not log the operator out and an expired session does. The CHANGELOG records the API status change.
  • Tests cover the login 401 path including a non-JSON fallback, change-password with an expired session (401 clears) and with a wrong current password (403 keeps the session), the openSSE constructor wiring, the absence of Content-Type on the three FormData uploads, and the direct-network check parses the AST so comments, strings and test files cannot produce false positives.

Tests: test:auth 38/38, test:upload 7/7, test:sse 10/10, tsc --noEmit clean, go vet ./server clean, TestChangePassword passes.

- apiFetch treats a 401 from /auth/* as bad credentials, not as an
  expired session: the session is kept and the server message is
  exposed instead of reloading /login.
- Test the openSSE constructor wiring, the login 401 path, the absence
  of Content-Type on the three FormData uploads, and broaden the direct
  network check to window/globalThis/self fetch, XMLHttpRequest,
  EventSource and sendBeacon in .js, .mjs, .cjs and .jsx files.
- change-password returns 403 for a wrong current password and keeps 401
  for an invalid or expired session, like authInit's bad setup token.
- apiFetch only treats a 401 from /auth/login as bad credentials; every
  other 401 clears the session and returns to /login.
- Tests cover change-password with an expired session and with a wrong
  current password, and the direct-network check parses the AST so
  comments, strings and test files cannot produce false positives.
@BaaRai
BaaRai force-pushed the fix/web-auth-401-followup branch from 81e4091 to 15f1b1b Compare December 3, 2026 00:20
- Test the 401 login fallback when the body is not JSON.
- Flag bare sendBeacon calls and parse .js, .mjs and .cjs as JavaScript.
- Record the change-password 403 in the CHANGELOG.
@BaaRai
BaaRai merged commit 507309c into main Dec 3, 2026
7 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