diff --git a/src/Kunstmaan/AdminBundle/Entity/BaseUser.php b/src/Kunstmaan/AdminBundle/Entity/BaseUser.php index 61e8177353..f6b700e6c1 100644 --- a/src/Kunstmaan/AdminBundle/Entity/BaseUser.php +++ b/src/Kunstmaan/AdminBundle/Entity/BaseUser.php @@ -7,12 +7,13 @@ use Kunstmaan\AdminBundle\Validator\Constraints\PasswordRestrictions; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\EquatableInterface; +use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface; use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Mapping\ClassMetadata; -abstract class BaseUser implements UserInterface, EquatableInterface +abstract class BaseUser implements UserInterface, EquatableInterface, PasswordAuthenticatedUserInterface { /** * @ORM\Id diff --git a/src/Kunstmaan/AdminBundle/Repository/UserRepository.php b/src/Kunstmaan/AdminBundle/Repository/UserRepository.php index fa8a305d95..ceda183d60 100644 --- a/src/Kunstmaan/AdminBundle/Repository/UserRepository.php +++ b/src/Kunstmaan/AdminBundle/Repository/UserRepository.php @@ -3,11 +3,13 @@ namespace Kunstmaan\AdminBundle\Repository; use Doctrine\ORM\EntityRepository; +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 { /** * Get user(s) that have the specified role(s) @@ -36,4 +38,11 @@ public function getUsersByRole($role) return $qb->getQuery()->getResult(); } + + public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newEncodedPassword): void + { + $user->setPassword($newEncodedPassword); + + $this->getEntityManager()->flush(); + } }