public function testIncreaseCount() { $attempt = new AuthenticationAttempt(); $this->assertSame(0, $attempt->getAttemptCount()); $attempt->increaseAttemptCount()->increaseAttemptCount(); $this->assertSame(2, $attempt->getAttemptCount()); }
public function testIncreaseCount() { $attempt = new AuthenticationAttempt(); $this->assertSame(0, $attempt->getAttemptCount()); $attempt->increaseAttemptCount()->increaseAttemptCount(); $this->assertSame(2, $attempt->getAttemptCount()); $this->assertCount(2, $attempt->getLastFailedAttemptTimesInRange()); $this->assertSame($attempt->getLatestFailedAttemptTime(), $attempt->getLastFailedAttemptTimesInRange()[0]); }
/** * Checks if enough failed authentications are done in the past to rise an auth warning. * * @param AuthenticationAttempt $attempt * @param \AppBundle\Model\User\Util\Date\DateTimeComparison $comparison * * @return bool */ private function needsAuthWarning(AuthenticationAttempt $attempt, DateTimeComparison $comparison) : bool { $count = $attempt->getAttemptCount(); if (self::MAX_FAILED_ATTEMPTS_FROM_IP <= $count) { if ($count - 3 === 0) { return true; } return !$this->isPreviouslyLoginFailed('-6 hours', $comparison, true); } return false; }