From b254603fb1a5a3a43f65cb2d29e54c9ce9dc4709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 5 Jul 2020 16:37:37 +0200 Subject: [PATCH] MAPG-185 add getter for expired users and password resetters --- src/Repository/UserPasswordResetterRepository.php | 10 ++++++++++ src/Repository/UserRepository.php | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Repository/UserPasswordResetterRepository.php b/src/Repository/UserPasswordResetterRepository.php index 466c3c8..47c70d7 100644 --- a/src/Repository/UserPasswordResetterRepository.php +++ b/src/Repository/UserPasswordResetterRepository.php @@ -1,5 +1,7 @@ pdm->selectFromDb($select, UserPasswordResetter::class); } + + public function getAllExpired(): Generator + { + $select = new Select(\Container::$dbConnection); + $select->where('expires', '<', (new DateTime())->format('Y-m-d H:i:s')); + + yield from $this->pdm->selectMultipleFromDb($select, UserPasswordResetter::class); + } } diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index c7ddcaf..be96c79 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -1,5 +1,7 @@ pdm->selectFromDb($select, User::class); } + + public function getAllInactiveExpired(): Generator + { + $select = new Select(\Container::$dbConnection); + $select->where('active', '=', false); + $select->where('created', '<', (new DateTime('-1 day'))->format('Y-m-d H:i:s')); + + yield from $this->pdm->selectMultipleFromDb($select, User::class); + } }