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:
@@ -95,6 +95,52 @@ class InviteTest extends TestCase
|
||||
self::assertFalse($invite->isAcceptable('2026-06-02 09:00:00'));
|
||||
}
|
||||
|
||||
public function testGroupInviteHonoursExplicitExpiry(): void
|
||||
{
|
||||
$invite = new Invite(
|
||||
'',
|
||||
'tok',
|
||||
createdAt: '2026-06-01 09:00:00',
|
||||
kind: Invite::KIND_GROUP,
|
||||
expiresAt: '2026-08-31 23:59:59'
|
||||
);
|
||||
|
||||
self::assertTrue($invite->isGroup());
|
||||
// 19 days after creation — past the personal 14-day window, but the
|
||||
// explicit expiry governs.
|
||||
self::assertFalse($invite->isExpired('2026-06-20 09:00:00'));
|
||||
self::assertTrue($invite->isAcceptable('2026-06-20 09:00:00'));
|
||||
|
||||
self::assertTrue($invite->isExpired('2026-09-01 00:00:00'));
|
||||
self::assertFalse($invite->isAcceptable('2026-09-01 00:00:00'));
|
||||
}
|
||||
|
||||
public function testExplicitExpiryWinsOverCreationWindowForPersonalInvites(): void
|
||||
{
|
||||
$invite = new Invite('[email protected]', 'tok', createdAt: '2026-06-01 09:00:00', expiresAt: '2026-06-02 23:59:59');
|
||||
|
||||
// One day old (inside the 14-day window) but past its explicit expiry.
|
||||
self::assertTrue($invite->isExpired('2026-06-03 09:00:00'));
|
||||
}
|
||||
|
||||
public function testFromRowDefaultsKindWhenColumnMissing(): void
|
||||
{
|
||||
$invite = Invite::fromRow((object) [
|
||||
'id' => '5',
|
||||
'email' => '[email protected]',
|
||||
'token' => 'tok123',
|
||||
'role' => RoleManager::STUDENT,
|
||||
'status' => Invite::STATUS_PENDING,
|
||||
'invited_by' => null,
|
||||
'accepted_user_id' => null,
|
||||
'accepted_at' => null,
|
||||
]);
|
||||
|
||||
self::assertSame(Invite::KIND_PERSONAL, $invite->kind);
|
||||
self::assertFalse($invite->isGroup());
|
||||
self::assertNull($invite->expiresAt);
|
||||
}
|
||||
|
||||
public function testHashTokenIsDeterministicSha256(): void
|
||||
{
|
||||
$hash = Invite::hashToken('raw-token');
|
||||
@@ -109,7 +155,7 @@ class InviteTest extends TestCase
|
||||
{
|
||||
$arr = (new Invite('[email protected]', 'tok', id: 1))->toArray();
|
||||
|
||||
foreach (['id', 'email', 'token', 'role', 'status', 'invited_by', 'accepted_user_id', 'accepted_at'] as $key) {
|
||||
foreach (['id', 'email', 'token', 'role', 'kind', 'status', 'invited_by', 'accepted_user_id', 'accepted_at', 'expires_at'] as $key) {
|
||||
self::assertArrayHasKey($key, $arr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user