MAPG-142 modify UserPasswordResetterRepository to return only one resetter for user
(it is not possible for an user to have multiple)
This commit is contained in:
parent
32392590bd
commit
37094e552b
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php namespace MapGuesser\Repository;
|
||||
|
||||
use Generator;
|
||||
use MapGuesser\Database\Query\Select;
|
||||
use MapGuesser\PersistentData\Model\User;
|
||||
use MapGuesser\PersistentData\Model\UserPasswordResetter;
|
||||
@ -28,11 +27,11 @@ class UserPasswordResetterRepository
|
||||
return $this->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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user