feat(auth): bounce to /login.html on 401 so AUTH_ENABLED=true gives a real login #26
No reviewers
Labels
No labels
bug
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: WildDragonLLC/dragonflight#26
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/auth-login-redirect"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The login flow already exists end-to-end (the form is in services/web-ui/public/login.html, backed by
POST /api/v1/auth/loginandPOST /api/v1/auth/setup), but the SPA never bounces to it. FlippingAUTH_ENABLED=trueonmam-apitoday would just leave the app stuck on the loading screen because/auth/mewould401and the wrapper would silently throw.This adds a single check in
apiFetch: any401redirects to/login.html(unless we're already there).Behaviour
AUTH_ENABLED=false(current state):/auth/mereturns the synthetic operator with200, the new branch is dormant, nothing changes.AUTH_ENABLED=true, no session: any API call (the page boots by fetching/projects,/assets,/recorders,/auth/me, etc.) hits401, the wrapper redirects to/login.html. The operator runs the "Create admin account" flow once, signs in, and lands onhome.htmlwith a real session./login.html, the redirect is skipped (login.html uses its ownfetch, notapiFetch, so this is defensive).Roll-out
AUTH_ENABLED=false)./mnt/NVME/MAM/wild-dragon/.envon TrueNAS: setAUTH_ENABLED=trueand a non-defaultSESSION_SECRET.mam-api./login.html→ "Create admin account" → sign in.Test plan
/— page still loads as before (auth still off, synthetic user shows in sidebar)AUTH_ENABLED=trueand restart mam-api; reload the app — redirect to/login.html/login.html🤖 Generated with Claude Code