Lock the registration email to the invite only when the invite is redeemable #82

Merged
thatguygriff merged 1 commits from fix/invite-email-lock into main 2026-07-22 13:31:17 +00:00
Owner

Closes #78

What & why

From the user demo: registering from a personal invite link must show the invited email pre-filled and unchangeable.

Current main already renders the email read-only — but keyed off any invite row matching the token, valid or not. With open registration enabled, a stale token (expired / already accepted / revoked) showed the stale invite's address read-only while the submit handler took the open-registration branch and required a posted email that the locked field never submits (it has no name), dead-ending the form with "Please enter a valid email address."

RegistrationPage::render() now computes $inviteValid (Invite::isAcceptable()) once and the template locks the email exactly when the invite is redeemable; a stale token with open registration on falls back to the normal editable field. The server side was already safe — on submit a valid invite's stored address is always used, so a tampered client value is ignored; that behaviour is unchanged and now covered by rendering tests.

Tests

  • RegistrationPageTest::testValidInviteRendersEmailPrefilledAndLocked — read-only invited address, no editable name="email" input.
  • RegistrationPageTest::testStaleInviteWithOpenRegistrationShowsEditableEmail — editable field, stale address absent.
  • composer test — 367 tests pass; composer lint (PHPStan level 10) and composer cs clean.

Docs updated: docs/features/account-registration.md.

🤖 Generated with Claude Code

Closes #78 ## What & why From the user demo: registering from a **personal invite link** must show the invited email pre-filled and unchangeable. Current `main` already renders the email read-only — but keyed off *any* invite row matching the token, valid or not. With open registration enabled, a stale token (expired / already accepted / revoked) showed the stale invite's address read-only while the submit handler took the open-registration branch and required a posted `email` that the locked field never submits (it has no `name`), dead-ending the form with "Please enter a valid email address." `RegistrationPage::render()` now computes `$inviteValid` (`Invite::isAcceptable()`) once and the template locks the email **exactly when the invite is redeemable**; a stale token with open registration on falls back to the normal editable field. The server side was already safe — on submit a valid invite's stored address is always used, so a tampered client value is ignored; that behaviour is unchanged and now covered by rendering tests. ## Tests - `RegistrationPageTest::testValidInviteRendersEmailPrefilledAndLocked` — read-only invited address, no editable `name="email"` input. - `RegistrationPageTest::testStaleInviteWithOpenRegistrationShowsEditableEmail` — editable field, stale address absent. - `composer test` — 367 tests pass; `composer lint` (PHPStan level 10) and `composer cs` clean. Docs updated: `docs/features/account-registration.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thatguygriff added 1 commit 2026-07-22 13:25:20 +00:00
Lock the registration email to the invite only when the invite is redeemable
CI / Tests (PHP 8.1) (pull_request) Successful in 43s
CI / Tests (PHP 8.2) (pull_request) Successful in 37s
CI / PHPStan (pull_request) Successful in 2m45s
CI / Build Plugin Zip (pull_request) Skipped
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 2m49s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m42s
681fc5ae07
The register form keyed the read-only, prefilled email off any invite row
matching the token. A stale token (expired / accepted / revoked) with open
registration on therefore showed the stale invite's address read-only while
the submit handler took the open branch and required a posted email the
locked field never submits, dead-ending the form. The lock now applies
exactly when the invite is acceptable; otherwise the editable field renders.

Closes #78

Co-Authored-By: Claude Fable 5 <[email protected]>
thatguygriff merged commit b89a44047d into main 2026-07-22 13:31:17 +00:00
thatguygriff deleted branch fix/invite-email-lock 2026-07-22 13:31:17 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Unsupervised/unsupervised-scheduler#82