From e81f8be151e962eef7392022468cc5420618530a Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 28 Feb 2022 09:35:54 +0100 Subject: [PATCH] remove password generation from the user factory --- core/Factory/UserFactory.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/Factory/UserFactory.php b/core/Factory/UserFactory.php index 9d4d4bc..0218062 100644 --- a/core/Factory/UserFactory.php +++ b/core/Factory/UserFactory.php @@ -16,9 +16,8 @@ class UserFactory implements FactoryInterface protected TokenGeneratorInterface $tokenGenerator; protected UserPasswordEncoderInterface $encoder; - public function __construct(TokenGeneratorInterface $tokenGenerator, UserPasswordEncoderInterface $encoder) + public function __construct(UserPasswordEncoderInterface $encoder) { - $this->tokenGenerator = $tokenGenerator; $this->encoder = $encoder; } @@ -26,14 +25,13 @@ class UserFactory implements FactoryInterface { $entity = new User(); - if (!empty($email)) { + if (null !== $email) { $entity->setEmail($email); } - $entity->setPassword($this->encoder->encodePassword( - $entity, - !empty($password) ? $password : $this->tokenGenerator->generateToken() - )); + if (null !== $email) { + $entity->setPassword($this->encoder->encodePassword($entity, $password)); + } return $entity; }