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
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
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]>
This commit is contained in:
@@ -56,8 +56,9 @@ class RegistrationPageTest extends TestCase
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$_POST = [];
|
||||
$_GET = [];
|
||||
$_POST = [];
|
||||
$_GET = [];
|
||||
$_REQUEST = [];
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
@@ -176,6 +177,47 @@ class RegistrationPageTest extends TestCase
|
||||
self::assertStringContainsString('<form', $html);
|
||||
}
|
||||
|
||||
public function testValidInviteRendersEmailPrefilledAndLocked(): void
|
||||
{
|
||||
$_REQUEST = ['us_invite' => 'raw-token'];
|
||||
$this->stubRenderContext();
|
||||
|
||||
$invite = new Invite(email: '[email protected]', token: 'hash', createdAt: '2024-01-01 00:00:00', id: 9);
|
||||
$this->ctx['invites']->shouldReceive('findByToken')
|
||||
->once()
|
||||
->with(Invite::hashToken('raw-token'))
|
||||
->andReturn($invite);
|
||||
|
||||
$html = $this->ctx['page']->render([]);
|
||||
|
||||
// The invited address is shown read-only; there is no editable email input.
|
||||
self::assertStringContainsString('value="[email protected]" readonly', $html);
|
||||
self::assertStringNotContainsString('name="email"', $html);
|
||||
}
|
||||
|
||||
public function testStaleInviteWithOpenRegistrationShowsEditableEmail(): void
|
||||
{
|
||||
$_REQUEST = ['us_invite' => 'raw-token'];
|
||||
$this->stubRenderContext();
|
||||
|
||||
// Already-redeemed invite: not acceptable, so the open-registration form
|
||||
// must collect an email rather than showing the stale locked address.
|
||||
$invite = new Invite(
|
||||
email: '[email protected]',
|
||||
token: 'hash',
|
||||
status: Invite::STATUS_ACCEPTED,
|
||||
createdAt: '2024-01-01 00:00:00',
|
||||
id: 9
|
||||
);
|
||||
$this->ctx['invites']->shouldReceive('findByToken')->once()->andReturn($invite);
|
||||
|
||||
$html = $this->ctx['page']->render([]);
|
||||
|
||||
self::assertStringContainsString('name="email"', $html);
|
||||
self::assertStringNotContainsString('[email protected]', $html);
|
||||
self::assertStringNotContainsString('readonly', $html);
|
||||
}
|
||||
|
||||
public function testRejectsWhenARequiredPolicyIsUnaccepted(): void
|
||||
{
|
||||
$_POST = [ 'password' => 'password123', 'display_name' => 'Ada', 'email' => '[email protected]' ];
|
||||
|
||||
Reference in New Issue
Block a user