feat(auth): implement login security features including account locking and login attempt tracking

This commit is contained in:
2026-07-29 10:47:26 -03:00
parent 45553dc514
commit 7c9ebc6d4d
18 changed files with 578 additions and 17 deletions

View File

@@ -18,6 +18,11 @@ class ResetPasswordControllerTest extends TestCase
'email' => 'ada@example.com',
'password' => 'OldSecret!123',
]);
$user->forceFill([
'failed_login_attempts' => 5,
'last_failed_login_at' => now(),
'locked_until' => now()->addMinutes(15),
])->save();
$user->createToken('existing-session');
$attempt = $user->resetPasswordAttempts()->create([
'codigo' => '0123',
@@ -38,6 +43,9 @@ class ResetPasswordControllerTest extends TestCase
$this->assertFalse(Hash::check('OldSecret!123', $user->password));
$this->assertSame(ResetPasswordAttempt::STATUS_USED, $attempt->fresh()->status);
$this->assertDatabaseCount('personal_access_tokens', 0);
$this->assertSame(0, $user->failed_login_attempts);
$this->assertNull($user->last_failed_login_at);
$this->assertNull($user->locked_until);
}
public function test_it_rejects_a_pending_expired_or_used_attempt(): void