From 37094e552bf5131ae283700ca06eb7b89f0b4a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 5 Jul 2020 13:22:22 +0200 Subject: [PATCH] MAPG-142 modify UserPasswordResetterRepository to return only one resetter for user (it is not possible for an user to have multiple) --- src/Controller/UserController.php | 3 ++- src/Repository/UserPasswordResetterRepository.php | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index f285318..4b0e26f 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -196,7 +196,8 @@ class UserController implements ISecured $this->pdm->deleteFromDb($userConfirmation); } - foreach ($this->userPasswordResetterRepository->getByUser($user) as $userPasswordResetter) { + $userPasswordResetter = $this->userPasswordResetterRepository->getByUser($user); + if ($userPasswordResetter !== null) { $this->pdm->deleteFromDb($userPasswordResetter); } diff --git a/src/Repository/UserPasswordResetterRepository.php b/src/Repository/UserPasswordResetterRepository.php index 04a82af..466c3c8 100644 --- a/src/Repository/UserPasswordResetterRepository.php +++ b/src/Repository/UserPasswordResetterRepository.php @@ -1,6 +1,5 @@ pdm->selectFromDb($select, UserPasswordResetter::class); } - public function getByUser(User $user): Generator + public function getByUser(User $user): ?UserPasswordResetter { $select = new Select(\Container::$dbConnection); $select->where('user_id', '=', $user->getId()); - yield from $this->pdm->selectMultipleFromDb($select, UserPasswordResetter::class); + return $this->pdm->selectFromDb($select, UserPasswordResetter::class); } }