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); } }