- AuthenticateSession in the web group logs out a user's other sessions when their password changes. - Set-password links made by an admin use a new admin_links broker with its own password_setup_tokens table and a 72-hour expiry, so links handed over by hand don't expire in an hour. Forgot-password links keep 60 minutes. The reset page accepts both, and issuing or using a link ends the user's earlier links. - Admin links are emailed with PasswordSetupLinkNotification; the email body is shared with the forgot-password email via PasswordLinkMail. - Spec chapter 3 and CLAUDE.md describe the link lifetimes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use App\Modules\Users\Domain\Enums\Role;
|
|
use App\Modules\Users\Infrastructure\Auth\PasswordSetupLinkNotification;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Notification;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('creates an admin, emails a set-password link and prints it', function () {
|
|
Notification::fake();
|
|
|
|
$this->artisan('users:create-admin', ['name' => 'Anna Admin', 'email' => '[email protected]'])
|
|
->expectsOutputToContain('/reset-password/')
|
|
->assertSuccessful();
|
|
|
|
$admin = User::query()->sole();
|
|
|
|
expect($admin->role)->toBe(Role::Admin)
|
|
->and($admin->email)->toBe('[email protected]');
|
|
|
|
Notification::assertSentTo($admin, PasswordSetupLinkNotification::class);
|
|
});
|
|
|
|
it('fails for an email address that is in use', function () {
|
|
User::factory()->create(['email' => '[email protected]']);
|
|
|
|
$this->artisan('users:create-admin', ['name' => 'Anna Admin', 'email' => '[email protected]'])
|
|
->assertFailed();
|
|
|
|
expect(User::query()->count())->toBe(1);
|
|
});
|