diff options
-rw-r--r-- | Core/Authentication/Token/AbstractToken.php | 8 | ||||
-rw-r--r-- | Core/Authentication/Token/RememberMeToken.php | 11 |
2 files changed, 16 insertions, 3 deletions
diff --git a/Core/Authentication/Token/AbstractToken.php b/Core/Authentication/Token/AbstractToken.php index 3839154..210e46d 100644 --- a/Core/Authentication/Token/AbstractToken.php +++ b/Core/Authentication/Token/AbstractToken.php @@ -84,11 +84,15 @@ abstract class AbstractToken implements TokenInterface if (null === $this->user) { $changed = false; } else if ($this->user instanceof UserInterface) { - $changed = $this->user->equals($user); + if (!$user instanceof UserInterface) { + $changed = true; + } else { + $changed = !$this->user->equals($user); + } } else if ($user instanceof UserInterface) { $changed = true; } else { - $changed = (string) $this->user === (string) $user; + $changed = (string) $this->user !== (string) $user; } if ($changed) { diff --git a/Core/Authentication/Token/RememberMeToken.php b/Core/Authentication/Token/RememberMeToken.php index a502cdb..038198a 100644 --- a/Core/Authentication/Token/RememberMeToken.php +++ b/Core/Authentication/Token/RememberMeToken.php @@ -48,7 +48,16 @@ class RememberMeToken extends AbstractToken $this->persistentToken = $persistentToken; $this->setUser($user); - $this->setAuthenticated(true); + parent::setAuthenticated(true); + } + + public function setAuthenticated($authenticated) + { + if ($authenticated) { + throw new \RuntimeException('You cannot set this token to authenticated after creation.'); + } + + parent::setAuthenticated(false); } public function getProviderKey() |