Skip to content

feat: invite-only registration (slice 28) - #29

Merged
dannyclarkdev merged 2 commits into
mainfrom
feat/invite-only-registration-slice-28
Sep 14, 2026
Merged

dannyclarkdev merged 2 commits into
mainfrom
feat/invite-only-registration-slice-28

Conversation

@dannyclarkdev

Copy link
Copy Markdown
Owner

What this does

The register page is closed to strangers. It takes two people: whoever holds a valid invite link, and the first person to reach an install that has no users yet. Everyone else gets a 403 that says to ask their GM for a link, and the login page stops offering to make an account. DEMGEM_REGISTRATION=open restores the public page.

How

  • Support\Auth\RegistrationGate is the one place that decides. It reads the mode, the session's invite token, and whether any user exists. Fortify's register view, CreateNewUser, and SignInWithDiscord's new-account step all ask it. Recorded in .ai/rules/auth.md.
  • The gate looks the token up on every call rather than remembering a flag, so an invite revoked between the tap and the form closes the door with it.
  • /invites/{token} is the front door for a guest now. It sits outside the auth group, shows the campaign and the role, offers "Create an account" and "Log in", and remembers the token and the intended URL. Register, login, and Discord all land back on the invite. Accepting stays behind auth.
  • "Continue with Discord" for someone nobody has seen is refused with a notice while the door is closed. A linked user still signs in.

Tests

  • New tests/Feature/Auth/InviteOnlyRegistrationTest.php: closed page and POST with a user present, the first-user exception, the guest invite round trip through register and Join, a revoked invite and a bogus token, open mode, an unknown mode read as invite, the login link, and a logged-in visitor.
  • DiscordLoginTest: refused while closed, linked user still signs in.
  • AcceptInviteTest and RegistrationTest: the guest path and the open-page assumption updated.
  • Full suite: 1487 passed, 1 skipped. Pint and Larastan clean.

After merge

Set DEMGEM_REGISTRATION=invite in the production env, or leave it unset, since invite is the default. Register the first account before that deploy, or right after: the empty install takes exactly one account on its own.

Plan: docs/plans/2026-09-13-feat-invite-only-registration-plan.md

The register page now takes two people: whoever holds a valid invite link,
and the first person to reach an install that has no users yet. Everyone
else gets a 403 that says to ask their GM for a link, and the login page
stops offering to make an account. DEMGEM_REGISTRATION=open restores the
public page.

Support\Auth\RegistrationGate is the one place that decides. Fortify's
register view, CreateNewUser, and SignInWithDiscord's new-account step all
ask it. The gate looks the session's token up on every call, so an invite
revoked between the tap and the form closes the door with it.

An invite link is the front door for a guest now: /invites/{token} sits
outside the auth group, shows the campaign and the role, offers "Create an
account" and "Log in", and remembers the token and the intended URL so
register, login, and Discord all land back on the invite.
@dannyclarkdev
dannyclarkdev merged commit 3934eda into main Sep 14, 2026
2 checks passed
@dannyclarkdev
dannyclarkdev deleted the feat/invite-only-registration-slice-28 branch September 14, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant