Initial Admin Account Setup on First Deploy #11
Reference in New Issue
Block a user
Delete Branch "%!s()"
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
When the service is first deployed and there are no users in the database, the UI should present a setup wizard prompting for creation of the first admin account. This bootstrap flow must only be available during initial deployment — once the first admin account is created, the feature is permanently disabled.
Requirements
Backend
New endpoint:
GET /api/v1/setup/status(unauthenticated){ "needs_setup": true }if thevolunteerstable has zero rows{ "needs_setup": false }otherwiseNew endpoint:
POST /api/v1/setup/admin(unauthenticated){ "name", "email", "password" }to create the first admin account403 Forbiddenrole = 'admin'Both endpoints should live in a new
internal/setuppackage following the existing domain-based packaging conventionFrontend
Setup page (
/setup)App-level routing guard
GET /api/v1/setup/statusneeds_setupistrue, redirect all routes to/setupneeds_setupisfalse, the/setuproute should redirect to/login(or dashboard if authenticated)Security Considerations
POST /api/v1/setup/adminendpoint must perform an atomic check-and-insert (e.g., within a transaction) to prevent race conditions where two simultaneous requests could both create admin accountsAcceptance Criteria
/setup/setupis no longer accessible (redirects away)POST /api/v1/setup/adminreturns 403 if any user already exists_test.gotests.test.tsxcoverageResolved by #2