From d14635769651f556acd25086e712dd7cd8c4749d Mon Sep 17 00:00:00 2001 From: Ralf Merz Date: Tue, 10 Mar 2020 15:35:04 +0100 Subject: [PATCH] [BUGFIX] When finding active bans, combine IP and username with OR Because the ban table stores two records for IP and username, the query to fetch them must use orX() to get a result. Resolves: issue #5 , https://github.com/WebentwicklerAt/typo3-loginlimit/issues/5 --- Classes/Domain/Repository/BanRepository.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Classes/Domain/Repository/BanRepository.php b/Classes/Domain/Repository/BanRepository.php index edc7fdd..8cc90a5 100644 --- a/Classes/Domain/Repository/BanRepository.php +++ b/Classes/Domain/Repository/BanRepository.php @@ -74,13 +74,16 @@ public function findActiveBan(string $ip, string $username, int $bantime): array $table = $this->getTable(); $queryBuilder = $this->instantiateQueryBuilderForTable($table); + $or = $queryBuilder->expr()->orX(); + $or->add($queryBuilder->expr() + ->eq('ip', $queryBuilder->createNamedParameter($ip))); + $or->add($queryBuilder->expr() + ->eq('username', $queryBuilder->createNamedParameter($username))); + $queryBuilder ->select('*') ->from($table) - ->where( - $queryBuilder->expr()->eq('ip', $queryBuilder->createNamedParameter($ip)), - $queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username)) - ); + ->where($or); if ($bantime >= 0) { $queryBuilder->andWhere(