MAPG-142 modify UserConfirmationRepository to return only one confirmation for user
(it is not possible for an user to have multiple)
This commit is contained in:
parent
631582a912
commit
6cafac1b65
@ -184,7 +184,8 @@ class UserController implements ISecured
|
|||||||
|
|
||||||
\Container::$dbConnection->startTransaction();
|
\Container::$dbConnection->startTransaction();
|
||||||
|
|
||||||
foreach ($this->userConfirmationRepository->getByUser($user) as $userConfirmation) {
|
$userConfirmation = $this->userConfirmationRepository->getByUser($user);
|
||||||
|
if ($userConfirmation !== null) {
|
||||||
$this->pdm->deleteFromDb($userConfirmation);
|
$this->pdm->deleteFromDb($userConfirmation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<?php namespace MapGuesser\Repository;
|
<?php namespace MapGuesser\Repository;
|
||||||
|
|
||||||
use Generator;
|
|
||||||
use MapGuesser\Database\Query\Select;
|
use MapGuesser\Database\Query\Select;
|
||||||
use MapGuesser\Interfaces\Database\IResultSet;
|
|
||||||
use MapGuesser\PersistentData\Model\User;
|
use MapGuesser\PersistentData\Model\User;
|
||||||
use MapGuesser\PersistentData\Model\UserConfirmation;
|
use MapGuesser\PersistentData\Model\UserConfirmation;
|
||||||
use MapGuesser\PersistentData\PersistentDataManager;
|
use MapGuesser\PersistentData\PersistentDataManager;
|
||||||
@ -29,11 +27,11 @@ class UserConfirmationRepository
|
|||||||
return $this->pdm->selectFromDb($select, UserConfirmation::class);
|
return $this->pdm->selectFromDb($select, UserConfirmation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getByUser(User $user): Generator
|
public function getByUser(User $user): ?UserConfirmation
|
||||||
{
|
{
|
||||||
$select = new Select(\Container::$dbConnection);
|
$select = new Select(\Container::$dbConnection);
|
||||||
$select->where('user_id', '=', $user->getId());
|
$select->where('user_id', '=', $user->getId());
|
||||||
|
|
||||||
yield from $this->pdm->selectMultipleFromDb($select, UserConfirmation::class);
|
return $this->pdm->selectFromDb($select, UserConfirmation::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user