summaryrefslogtreecommitdiffstats
path: root/Core/Authentication/Token
diff options
context:
space:
mode:
authorJohannes M. Schmitt <schmittjoh@gmail.com>2011-03-09 09:56:08 +0100
committerJohannes M. Schmitt <schmittjoh@gmail.com>2011-03-10 10:25:33 +0100
commitb447605b8450af3942f421513fd5ca45490615c1 (patch)
tree8f93be26d05afe9251662e5689a7634255844679 /Core/Authentication/Token
parent4ad18ddf07435fe6fcb5ac47ef099419b0ad5a5b (diff)
downloadsymfony-security-b447605b8450af3942f421513fd5ca45490615c1.zip
symfony-security-b447605b8450af3942f421513fd5ca45490615c1.tar.gz
symfony-security-b447605b8450af3942f421513fd5ca45490615c1.tar.bz2
[Security] added some more tests
Diffstat (limited to 'Core/Authentication/Token')
-rw-r--r--Core/Authentication/Token/AbstractToken.php8
-rw-r--r--Core/Authentication/Token/RememberMeToken.php11
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()