From f9a05d2199dbec989e7d53f5c983e601016846c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 12 Dec 2023 18:02:03 +0100 Subject: [PATCH] Add password upgrade feature --- Repository/UserRepository.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Repository/UserRepository.php b/Repository/UserRepository.php index d75e229..da5952f 100644 --- a/Repository/UserRepository.php +++ b/Repository/UserRepository.php @@ -13,11 +13,13 @@ namespace Rapsys\UserBundle\Repository; use Doctrine\ORM\Query\ResultSetMapping; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; +use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; /** * UserRepository */ -class UserRepository extends EntityRepository { +class UserRepository extends EntityRepository implements PasswordUpgraderInterface { /** * Find user count as int * @@ -142,4 +144,15 @@ SQL; //Send result return $ret; } + + /** + * {@inheritdoc} + */ + public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $hash): void { + //Set new hashed password + $user->setPassword($hash); + + //Flush data to database + $this->getEntityManager()->flush(); + } } -- 2.41.1