Skip to content
This repository was archived by the owner on Oct 31, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/Db/DbService.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public function addFailedLoginAttempt($uid, $ip){
public function getSuspiciousActivityCountForUid($uid) {
$builder = $this->connection->getQueryBuilder();
$thresholdTime = (new \DateTime())->modify("-86400 second")->getTimestamp();
$attempts = $builder->select('*')
$attempts = $builder->selectAlias($builder->createFunction('COUNT(*)'), 'count')
->from('failed_login_attempts')
->where($builder->expr()->gt('attempted_at', $builder->createNamedParameter($thresholdTime)))
->andWhere($builder->expr()->eq('uid', $builder->createNamedParameter($uid)))
->execute()
->fetchAll();
return count($attempts);
->fetch();
return intval($attempts['count']);
}

/**
Expand All @@ -86,13 +86,13 @@ public function getSuspiciousActivityCountForUid($uid) {
public function getSuspiciousActivityCountForIp($ip) {
$builder = $this->connection->getQueryBuilder();
$thresholdTime = (new \DateTime())->modify("-86400 second")->getTimestamp();
$attempts = $builder->select('*')
$attempts = $builder->selectAlias($builder->createFunction('COUNT(*)'), 'count')
->from('failed_login_attempts')
->where($builder->expr()->gt('attempted_at', $builder->createNamedParameter($thresholdTime)))
->andWhere($builder->expr()->eq('ip', $builder->createNamedParameter($ip)))
->execute()
->fetchAll();
return count($attempts);
->fetch();
return intval($attempts['count']);
}

public function deleteSuspiciousAttemptsForIp($ip) {
Expand Down