]> Raphaël G. Git Repositories - userbundle/commitdiff
Add password upgrade feature 0.3.4
authorRaphaël Gertz <git@rapsys.eu>
Tue, 12 Dec 2023 17:02:03 +0000 (18:02 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 12 Dec 2023 17:02:03 +0000 (18:02 +0100)
Repository/UserRepository.php

index d75e229959d12b4ccacb903f73d8c574839ba40e..da5952fa5a05bba066c634e3740f5ddc10e7c072 100644 (file)
@@ -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();
+       }
 }