Auth
Authentication behavior is split across shared auth infrastructure and feature implementations.
For a full lifecycle walkthrough and backend adaptation guide, read Auth Deep Dive.
Shared auth infrastructure
Located in src/common/auth:
use-auth.ts: session query state (user,isAuthenticated,logout, etc.).private-route.tsx: guards protected application routes.public-route.tsx: prevents authenticated users from revisiting auth pages.auth-manager.tsx: handles global auth loading state.auth-hooks.ts: HTTP hook integration concerns.
Feature flows
- Login:
src/features/login - Register:
src/features/register - MFA:
src/features/mfa - OAuth callback:
src/features/oauth
API endpoints in use
POST /api/auth/registerPOST /api/auth/loginPOST /api/auth/verify-mfaGET /api/auth/mePOST /api/auth/logoutGET /api/auth/oauth/:provider/authorizePOST /api/auth/oauth/:provider/callback
Flow summary
- User signs in using credentials or OAuth.
- Handlers call feature-specific auth data-access functions (for example
~/data-access/auth/auth.api). - Successful responses populate the user query state.
- Guards route users to app or auth pages based on session presence.
A special case is MFA: login can throw MfaRequiredError and route to the MFA page.