feat(auth): harden authentication and add configurable two-factor support

This commit is contained in:
2026-07-31 03:12:46 +02:00
parent 235d5f646c
commit e47243f7dc
51 changed files with 2904 additions and 1359 deletions

View File

@@ -8,6 +8,10 @@ use Illuminate\Support\Facades\URL;
uses(RefreshDatabase::class);
beforeEach(function () {
config(['auth-ui.features.two_factor_required' => false]);
});
it('does not send verification email when feature is disabled', function () {
config(['auth-ui.features.email_verification' => false]);
@@ -18,8 +22,8 @@ it('does not send verification email when feature is disabled', function () {
'first_name' => 'Test',
'last_name' => 'User',
'email' => 'test@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'password' => 'correct horse battery staple',
'password_confirmation' => 'correct horse battery staple',
]);
Notification::assertNothingSent();
@@ -35,8 +39,8 @@ it('sends verification email when feature is enabled', function () {
'first_name' => 'Test',
'last_name' => 'User',
'email' => 'test@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'password' => 'correct horse battery staple',
'password_confirmation' => 'correct horse battery staple',
]);
$user = User::where('email', 'test@example.com')->first();
@@ -135,8 +139,8 @@ it('redirects to verification notice after registration when feature is enabled'
'first_name' => 'New',
'last_name' => 'User',
'email' => 'new@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'password' => 'correct horse battery staple',
'password_confirmation' => 'correct horse battery staple',
])->assertRedirect('/email/verify');
});
@@ -148,7 +152,7 @@ it('redirects to home after registration when feature is disabled', function ()
'first_name' => 'New',
'last_name' => 'User',
'email' => 'new@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'password' => 'correct horse battery staple',
'password_confirmation' => 'correct horse battery staple',
])->assertRedirect('/dashboard');
});