feat(accounts): locked registration, for staging (#27)
Release / release (push) Successful in 4s
CI / test (push) Successful in 1m35s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 5s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 14s

Locks staging down before payments' staging (PayPal's sandbox) exists.

**The problem:** staging's registration is closed, but signing in with Discord still makes an approved basic account at once (`auth.ts`). So any Discord account can sign in to Music's staging.

**The change:** a third registration setting, `locked`:
- Every new account waits for a moderator's approval, Discord sign-ins too.
- Only approved accounts sign in to T5DE's other sites. The gate is the OAuth provider's `postLogin.shouldRedirect`: an unapproved account is sent to the website (which shows "Waiting for Approval") and no code is issued. It runs on every authorize request and on `/oauth2/continue`.
- Finishing setup under `locked` keeps the person's approval, so an approved basic account doesn't lose Music access by becoming a member.
- **Console:** the setting has a "Locked" option. **Website:** the waiting screen for unapproved Discord accounts, and the sign-up page's note.

`open` and `closed` behave as before. Under `closed`, a member waiting for approval still signs in to Music (tested), so prod doesn't change.

**After merging:** infra sets staging's `REGISTRATION` to `locked`. That's only a default: if staging's registration was ever changed in the console, set it to Locked there. Accounts already on staging keep their approval.

**Checks:** `bun test` (77 pass, two new tests), `check-types`, `lint`.

Locks staging down before payments' staging (PayPal's sandbox) exists.

**The problem:** staging's registration is closed, but signing in with Discord still makes an approved basic account at once (`auth.ts`). So any Discord account can sign in to Music's staging.

**The change:** a third registration setting, `locked`:
- Every new account waits for a moderator's approval, Discord sign-ins too.
- Only approved accounts sign in to T5DE's other sites. The gate is the OAuth provider's `postLogin.shouldRedirect`: an unapproved account is sent to the website (which shows "Waiting for Approval") and no code is issued. It runs on every authorize request and on `/oauth2/continue`.
- Finishing setup under `locked` keeps the person's approval, so an approved basic account doesn't lose Music access by becoming a member.
- **Console:** the setting has a "Locked" option. **Website:** the waiting screen for unapproved Discord accounts, and the sign-up page's note.

`open` and `closed` behave as before. Under `closed`, a member waiting for approval still signs in to Music (tested), so prod doesn't change.

**After merging:** infra sets staging's `REGISTRATION` to `locked`. That's only a default: if staging's registration was ever changed in the console, set it to Locked there. Accounts already on staging keep their approval.

**Checks:** `bun test` (77 pass, two new tests), `check-types`, `lint`.

Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #27.
This commit is contained in:
dhkatz authored and dhkatz committed 2026-11-20 20:31:32 +00:00
1 parent 02e8269d4d
commit f3cc3f9f17
11 files changed
+111 -22

No files matched your search

+7 -2
View File
@@ -69,9 +69,14 @@ export async function decideAccount(_: ActionState, form: FormData): Promise<Act
export async function setRegistration(_: ActionState, form: FormData): Promise<ActionState> {
return attempt(async () => {
const registration = field(form, "registration") === "closed" ? "closed" : "open";
const value = field(form, "registration");
const registration = value === "closed" || value === "locked" ? value : "open";
unwrap(await api.console.settings.put({ registration }));
revalidatePath("/console");
return registration === "closed" ? "Registration closed: new accounts wait for approval." : "Registration open.";
return registration === "locked"
? "Registration locked: every new account waits for approval, and only approved ones sign in to other sites."
: registration === "closed"
? "Registration closed: new accounts wait for approval."
: "Registration open.";
});
}