8000 Token was deauthenticated Error Symfony 4 by walterwhites · Pull Request #10151 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Token was deauthenticated Error Symfony 4 #10151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Token was deauthenticated Error Symfony 4
We should no long used Serializable interface in Symfony 4 it's caused error when you log with a user 'Token was deauthenticated after trying to refresh it'
we should use EquatableInterface and isEqualTo method
  • Loading branch information
walterwhites authored Jun 11, 2018
commit 9c5e79d4592ce0b50dc5106363107ccb584090eb
41 changes: 20 additions & 21 deletions security/entity_provider.rst
8000
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ with the following fields: ``id``, ``username``, ``password``,

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;

/**
* @ORM\Table(name="app_users")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User implements UserInterface, \Serializable
class User implements UserInterface, EquatableInterface
{
/**
* @ORM\Column(type="integer")
Expand Down Expand Up @@ -109,28 +110,26 @@ with the following fields: ``id``, ``username``, ``password``,
{
}

/** @see \Serializable::serialize() */
public function serialize()
/**
* The equality comparison should neither be done by referential equality
* nor by comparing identities (i.e. getId() === getId()).
*
* However, you do not need to compare every attribute, but only those that
* are relevant for assessing whether re-authentication is required.
*
* @return bool
*/
public function isEqualTo(UserInterface $user)
{
return serialize(array(
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
));
}
if ($this->password !== $user->getPassword()) {
6D2B return false;
}

/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt
) = unserialize($serialized, ['allowed_classes' => false]);
if ($this->email !== $user->getUsername()) {
return false;
}

return true;
}
}

Expand Down
0