feat(auth): close registration after the first user #28
No reviewers
Labels
No labels
bug
docs
duplicate
enhancement
help wanted
invalid
nice-to-have
pre-1.0
question
security
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jfro/lamplighter!28
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/12-close-registration"
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?
Closes #12.
Every account can change sources, AI keys and settings, so open registration made any signup an admin.
What changes
Accounts.register_user/1only registers while no account exists, unlessALLOW_REGISTRATION=true(runtime.exs, all envs but test). The check runs inside a transaction holding a Postgres advisory lock, so two people can't both register "first"./users/registerredirects to log in with "Registration is closed. An admin can open it with ALLOW_REGISTRATION=true." when closed; the login page drops its sign-up line.ALLOW_REGISTRATION.config/test.exssetsallow_registration: truesince fixtures register many users;registration_gate_test.exs(sync) turns it off and covers the first user, closing, the env var, and both pages. 3 of its 4 tests fail on main.The lock is taken only when the gate applies: taken in every register_user, it's held until the sandbox transaction ends and serialized async tests.
mix precommitpasses; full suite 8 runs in a row clean.Note: conflicts lightly with PR #25 (both touch registration.ex); I'll rebase whichever merges second.
Login after visiting /users/register with registration closed (dev, local mail adapter), desktop and 390px:


Review of #28 at
9b39320(Nye): looks good, ready.register_user/1is the only email path that creates users; the OIDC path (find_or_register_oidc_user) stays ungated as described.{:error, :registration_closed}. With the lock disabled, 4 of 6 got in on round 1, so the lock is doing the work.mix precommit: 628 tests pass. CI green.Non-blocking notes:
9b39320b476b140cd2a0