From d9ab2a6e1fc14f755d4463ded66406a6cb5c2356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 25 Apr 2025 08:15:45 +0200 Subject: [PATCH] fix: always update encrypted password This avoids issues with changed passwords or encryption keys --- src/Entity/User.php | 5 ++--- src/Security/BpnAuthenticator.php | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Entity/User.php b/src/Entity/User.php index bb712b2..7b8793e 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -18,7 +18,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface private ?string $email; #[ORM\Column(type: 'text')] - private ?string $password; + private ?string $password = null; #[ORM\Column(type: 'integer', nullable: true)] private ?int $personId = null; @@ -32,10 +32,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column(type: 'datetime_immutable', nullable: true)] private ?\DateTimeImmutable $lastLoginAt = null; - public function __construct(string $email, string $password) + public function __construct(string $email) { $this->email = $email; - $this->password = base64_encode($password); } public function getId(): ?int diff --git a/src/Security/BpnAuthenticator.php b/src/Security/BpnAuthenticator.php index 5c0e4b3..13470e1 100644 --- a/src/Security/BpnAuthenticator.php +++ b/src/Security/BpnAuthenticator.php @@ -87,11 +87,12 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent $userRepository = $this->entityManager->getRepository(User::class); if (null === $user = $userRepository->findOneBy(['email' => $email])) { - $user = new User($email, $encryptedPassword); + $user = new User($email); $this->entityManager->persist($user); } $user + ->setPassword($encryptedPassword) ->setPersonId($personId) ->setAddressId($addressId) ->setRoles($roles)