feat(auth): single-owner first-boot model#1
Merged
Conversation
Single-user per instance: the first registrant becomes the owner and registration is then permanently closed. - ownerExists() helper (user count > 0) in the auth package - databaseHooks.user.create.before rejects signups with FORBIDDEN once an owner exists, so no endpoint can create a second account - redirect funnel in /, /login, /signup based on owner existence and session
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
In the single-owner model the redirect funnel makes these links circular (/signup redirects to /login once an owner exists, and vice versa), so the 'Already have an account?' / 'Don't have an account?' prompts no longer apply.
Tears down the postgres volume and re-applies migrations for a clean slate, useful for testing the first-boot owner registration flow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the single-user / "first registrant becomes owner" model. MatchaChoice is one user per instance — no roles, no multi-user.
Changes
ownerExists()helper (usercount > 0) in@matchachoice/auth.databaseHooks.user.create.beforethrowsAPIError("FORBIDDEN", …)once an owner exists, so any endpoint hitting user-create (incl. directsignUpcalls) is rejected./→ logged in:/dashboard; owner exists:/login; else:/signup/login→ logged in:/dashboard; no owner yet:/signup/signup→ logged in:/dashboard; owner exists:/login/) was previously an ASCII landing; it is now the entry funnel.Out of scope (not built)
Roles, multi-user, invitations, password reset, OAuth/SSO, magic links.
Verification
pnpm check(Ultracite) — greenpnpm check-types— greenSKIP_ENV_VALIDATION=1 pnpm build— greenauth.api.signUpEmailcall is rejected withFORBIDDENand no second account is created.Notes for reviewer
beforehook has a theoretical TOCTOU race on simultaneous first-registrations; acceptable for a single-user self-hosted instance (low traffic, one-time event).empty DB → /signup → register → /dashboard) was validated by logic/build; not run live because the local dev DB already contains one user. Happy to verify on a throwaway DB if desired.