Skip to content

Phase 1 (frontend): login flow, auth context, workspace switcher#11

Merged
kosminus merged 1 commit into
mainfrom
claude/phase1-frontend-auth
Jun 5, 2026
Merged

Phase 1 (frontend): login flow, auth context, workspace switcher#11
kosminus merged 1 commit into
mainfrom
claude/phase1-frontend-auth

Conversation

@kosminus

@kosminus kosminus commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Frontend half of Phase 1, built against the auth API from #9 (now merged to main). Diff is frontend-only.

Session is an HTTP-only cookie, so the client never handles tokens — it sends credentials and derives auth state from /auth/me.

What's included

  • api/client.tswithCredentials, X-Workspace-Id request-header injector, global 401 → drop-session handler (auth endpoints excluded to avoid loops).
  • AuthContext + useAuth — loads /auth/me, exposes user/workspaces/role, persists the active-workspace choice, refresh/logout, resets the query cache on workspace switch + logout.
  • LoginPage — provider-aware (password + register toggle and/or magic-link, from GET /auth/providers); dev magic-link token surfaced locally. MagicLinkVerifyPage for /login/verify?token=.
  • ProtectedRoute + routing — public /login + /login/verify, app routes gated.
  • AppLayout header — workspace switcher, role badge, account menu with sign-out.

Verification

  • npm run build (tsc + vite) — clean
  • npm run lint — clean
  • No new dependencies.

Note

Replaces #10 (auto-closed when the stacked base branch was deleted on merge of #9). End-to-end browser verification needs the backend running with DISABLE_AUTH=false.

🤖 Generated with Claude Code

Frontend half of Phase 1, built against the new auth API. Session is an
HTTP-only cookie, so the client never handles tokens — it sends credentials
and derives auth state from /auth/me.

- client.ts: withCredentials, X-Workspace-Id request header, global 401 ->
  drop-session handler (auth endpoints excluded to avoid loops)
- AuthContext + useAuth: loads /auth/me, exposes user/workspaces/role,
  active-workspace selection (persisted), refresh/logout, query-cache reset
  on workspace switch + logout
- LoginPage: provider-aware (password + register toggle, magic-link), dev
  token surfaced for local magic-link; MagicLinkVerifyPage for /login/verify
- ProtectedRoute guard; App.tsx public /login + /login/verify, app routes
  gated behind auth
- AppLayout header: workspace switcher, role badge, account menu with sign-out
- authApi client + auth types

Builds (tsc + vite) and lints clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kosminus kosminus merged commit 9838c37 into main Jun 5, 2026
4 checks passed
@kosminus kosminus deleted the claude/phase1-frontend-auth branch June 5, 2026 11:16
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