Add multi-use group invite links with expiry and auto-approval on email confirmation
CI / Tests (PHP 8.2) (pull_request) Successful in 44s
CI / Tests (PHP 8.1) (pull_request) Successful in 46s
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 2m46s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m38s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.2) (pull_request) Successful in 44s
CI / Tests (PHP 8.1) (pull_request) Successful in 46s
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 2m46s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m38s
CI / Build Plugin Zip (pull_request) Skipped
A studio admin can generate a shareable group invite link (e.g. for a newsletter) from the Invites page, choosing a required expiry date. Anyone with the link may register while it is valid, in any registration mode: the form collects their own email, they must confirm it via the usual hashed token, and confirming approves the account immediately — group signups never enter the Pending Students queue. - us_invites grows kind (personal/group) and expires_at; an explicit expiry wins over the personal 14-day window. Group links stay pending (multi-use) until revoked or expired. - RegistrationPage: group signups create the account pending with the us_auto_approve marker and send the confirmation email; no auto-login. - EmailConfirmationHandler: auto-approve accounts are approved on confirmation, emailed the approved notice, and redirected to a new us_confirmed=ready notice with a sign-in link. Closes #77 Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -34,16 +34,40 @@ class InviteRepositoryTest extends TestCase
|
||||
Mockery::on(static function (array $d): bool {
|
||||
return $d['email'] === '[email protected]'
|
||||
&& $d['token'] === 'tok123'
|
||||
&& $d['kind'] === Invite::KIND_PERSONAL
|
||||
&& $d['status'] === Invite::STATUS_PENDING
|
||||
&& $d['invited_by'] === 2;
|
||||
&& $d['invited_by'] === 2
|
||||
&& $d['expires_at'] === null;
|
||||
}),
|
||||
['%s', '%s', '%s', '%s', '%d', '%d', '%s', '%s']
|
||||
['%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s', '%s', '%s']
|
||||
);
|
||||
$this->db->insert_id = 5;
|
||||
|
||||
self::assertSame(5, $this->repo->insert(new Invite('[email protected]', 'tok123', invitedBy: 2)));
|
||||
}
|
||||
|
||||
public function testInsertPersistsGroupKindAndExpiry(): void
|
||||
{
|
||||
Functions\expect('current_time')->with('mysql')->andReturn('2026-06-02 09:00:00');
|
||||
|
||||
$this->db->shouldReceive('insert')
|
||||
->once()
|
||||
->with(
|
||||
'wp_us_invites',
|
||||
Mockery::on(static function (array $d): bool {
|
||||
return $d['email'] === ''
|
||||
&& $d['kind'] === Invite::KIND_GROUP
|
||||
&& $d['expires_at'] === '2026-08-31 23:59:59';
|
||||
}),
|
||||
Mockery::type('array')
|
||||
);
|
||||
$this->db->insert_id = 6;
|
||||
|
||||
$invite = new Invite('', 'tok456', invitedBy: 2, kind: Invite::KIND_GROUP, expiresAt: '2026-08-31 23:59:59');
|
||||
|
||||
self::assertSame(6, $this->repo->insert($invite));
|
||||
}
|
||||
|
||||
public function testFindByTokenReturnsInvite(): void
|
||||
{
|
||||
$this->db->shouldReceive('prepare')
|
||||
|
||||
Reference in New Issue
Block a user