Skip to content

Commit

Permalink
Fix PasswordUpdater if password is null
Browse files Browse the repository at this point in the history
Sync User::password property with PasswordAuthenticatedUserInterface
  • Loading branch information
schvoy committed Sep 9, 2024
1 parent 3b793f9 commit 3f7f31c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.0.3

* Fix PasswordUpdater if password is null
* Sync User::password property with PasswordAuthenticatedUserInterface

## 1.0.2

* Improve the README.md
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class User extends IdBasedEntity implements UserInterface, PasswordAuthenticated
protected array $roles = [];

#[ORM\Column(type: Types::STRING)]
protected string $password;
protected ?string $password = null;

public function __toString()
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public function setRoles(array $roles): void
/**
* @see UserInterface
*/
public function getPassword(): string
public function getPassword(): ?string
{
return $this->password;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Security/PasswordUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function hashPassword(UserInterface $user, string $plainPassword): void
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
}

if (false === $this->userPasswordHasher->needsRehash($user)) {
if (
null !== $user->getPassword()
&& false === $this->userPasswordHasher->needsRehash($user)
) {
return;
}

Expand Down

0 comments on commit 3f7f31c

Please sign in to comment.