Skip to content

Commit

Permalink
Fix blocking account after successulf logins
Browse files Browse the repository at this point in the history
Related bug that caused inappropriate behavior: doctrine/orm#4491
  • Loading branch information
fracz committed Apr 9, 2018
1 parent f0f765d commit d52019e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function isAuthenticationFailureLimitExceeded(string $username): bool {
if ($request) {
$criteria->andWhere(Criteria::expr()->eq('ipv4', ip2long($request->getClientIp())));
}
$authEntries = $this->auditEntryRepository->matching($criteria);
$authEntries = $this->auditEntryRepository->matching($criteria)->toArray();
if (count($authEntries) === $this->maxFailedAttempts) {
foreach ($authEntries as $entry) {
/** @var AuditEntry $entry */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ public function init() {
}

public function testSavingSimpleAuditEntry() {
$this->audit->newEntry(AuditedEvent::AUTHENTICATION())->setTextParam('aaa')->buildAndFlush();
$this->audit->newEntry(AuditedEvent::AUTHENTICATION_SUCCESS())->setTextParam('aaa')->buildAndFlush();
$entries = $this->audit->getRepository()->findAll();
$this->assertCount(1, $entries);
/** @var AuditEntry $entry */
$entry = current($entries);
$this->assertEquals(AuditedEvent::AUTHENTICATION(), $entry->getEvent());
$this->assertEquals(AuditedEvent::AUTHENTICATION_SUCCESS(), $entry->getEvent());
$this->assertEquals('aaa', $entry->getTextParam());
$this->assertTrue($entry->isSuccessful());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function testAccountIsBlockedAfterThreeSuccessfulAndUnsuccessfulLogins()
$this->assertFailedLoginRequest($client);
$this->assertFailedLoginRequest($client);
$this->assertFailedLoginRequest($client, self::EMAIL, self::PASSWORD);
$this->assertCount(4, $this->audit->getRepository()->findAll());
$this->assertCount(7, $this->audit->getRepository()->findAll());
$latestEntry = $this->getLatestAuditEntry();
$this->assertEquals(AuthenticationFailureReason::BLOCKED, $latestEntry->getIntParam());
}
Expand Down

0 comments on commit d52019e

Please sign in to comment.