Skip to content

Commit

Permalink
Merge pull request #3039 from bobvandevijver/patch-3
Browse files Browse the repository at this point in the history
Update serializable interface
  • Loading branch information
bobdenotter authored Jan 19, 2022
2 parents 6c15cbc + 97a4b3f commit 65d4bc9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,26 @@ public function eraseCredentials(): void
*/
public function serialize(): string
{
return serialize([$this->id, $this->username, $this->password]);
return serialize($this->__serialize());
}

public function __serialize(): array
{
return [$this->id, $this->username, $this->password];
}

/**
* {@inheritdoc}
*/
public function unserialize($serialized): void
{
$this->__unserialize(unserialize($serialized, ['allowed_classes' => false]));
}

public function __unserialize(array $data): void
{
// add $this->salt too if you don't use Bcrypt or Argon2i
[$this->id, $this->username, $this->password] = unserialize($serialized, ['allowed_classes' => false]);
[$this->id, $this->username, $this->password] = $data;
}

public function getLastseenAt(): ?\DateTimeInterface
Expand Down

0 comments on commit 65d4bc9

Please sign in to comment.