From 8700352cf86d2d1b4acf5cb37715891794ef2d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 8 Apr 2024 13:21:34 +0200 Subject: [PATCH] Fix configuration and usage of password hasher --- .../Tests/Controller/UserControllerTest.php | 8 ++++---- src/Bundle/ChillMainBundle/config/services/form.yaml | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php index 8699aded5..073e07ff8 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Test\PrepareClientTrait; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; /** * @internal @@ -30,13 +31,12 @@ final class UserControllerTest extends WebTestCase { self::bootKernel(); $em = self::getContainer()->get(EntityManagerInterface::class); + /** @var UserPasswordHasherInterface::class $passwordHasher */ + $passwordHasher = self::getContainer()->get(UserPasswordHasherInterface::class); $user = new User(); $user->setUsername('Test_user '.uniqid()); - $user->setPassword(self::getContainer()->get(\Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface::class)->encodePassword( - $user, - 'password' - )); + $user->setPassword($passwordHasher->hashPassword($user, 'password')); $em->persist($user); $em->flush(); diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml index 86e78edfa..ce303701c 100644 --- a/src/Bundle/ChillMainBundle/config/services/form.yaml +++ b/src/Bundle/ChillMainBundle/config/services/form.yaml @@ -103,7 +103,6 @@ services: Chill\MainBundle\Form\UserPasswordType: arguments: $chillLogger: '@monolog.logger.chill' - $passwordEncoder: '@Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface' tags: - { name: form.type }