summaryrefslogtreecommitdiffstats
path: root/Core/User
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2015-10-05 17:17:54 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2015-10-05 17:17:54 +0200
commit427c50c174f7ae307d61a722da4ab53e87819041 (patch)
tree6d5a0c89a0065ac6cdeb0f2120cf283b7e45a241 /Core/User
parentd666540ae19bf54addb355f7ff325a6016608a33 (diff)
parent545528ff1e7a50a50b8e91f27bd667d66a140b14 (diff)
downloadsymfony-security-427c50c174f7ae307d61a722da4ab53e87819041.zip
symfony-security-427c50c174f7ae307d61a722da4ab53e87819041.tar.gz
symfony-security-427c50c174f7ae307d61a722da4ab53e87819041.tar.bz2
Merge branch '2.3' into 2.7
* 2.3: [Security][bugfix] "Remember me" cookie cleared on logout with custom "secure"/"httponly" config options [1] [ci] Use current PHP_BINARY when running ./phpunit Fixed typos [UPGRADE-3.0] fix bullet indentation [Security] InMemoryUserProvider now concerns whether user's password is changed when refreshing
Diffstat (limited to 'Core/User')
-rw-r--r--Core/User/InMemoryUserProvider.php37
1 files changed, 26 insertions, 11 deletions
diff --git a/Core/User/InMemoryUserProvider.php b/Core/User/InMemoryUserProvider.php
index 624eb3d..9aa39ca 100644
--- a/Core/User/InMemoryUserProvider.php
+++ b/Core/User/InMemoryUserProvider.php
@@ -67,17 +67,9 @@ class InMemoryUserProvider implements UserProviderInterface
*/
public function loadUserByUsername($username)
{
- if (!isset($this->users[strtolower($username)])) {
- $ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
- $ex->setUsername($username);
-
- throw $ex;
- }
+ $user = $this->getUser($username);
- $user = $this->users[strtolower($username)];
-
- return new User($user->getUsername(), $user->getPassword(), $user->getRoles(), $user->isEnabled(), $user->isAccountNonExpired(),
- $user->isCredentialsNonExpired(), $user->isAccountNonLocked());
+ return new User($user->getUsername(), $user->getPassword(), $user->getRoles(), $user->isEnabled(), $user->isAccountNonExpired(), $user->isCredentialsNonExpired(), $user->isAccountNonLocked());
}
/**
@@ -89,7 +81,9 @@ class InMemoryUserProvider implements UserProviderInterface
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
}
- return $this->loadUserByUsername($user->getUsername());
+ $storedUser = $this->getUser($user->getUsername());
+
+ return new User($storedUser->getUsername(), $storedUser->getPassword(), $storedUser->getRoles(), $storedUser->isEnabled(), $storedUser->isAccountNonExpired(), $storedUser->isCredentialsNonExpired() && $storedUser->getPassword() === $user->getPassword(), $storedUser->isAccountNonLocked());
}
/**
@@ -99,4 +93,25 @@ class InMemoryUserProvider implements UserProviderInterface
{
return $class === 'Symfony\Component\Security\Core\User\User';
}
+
+ /**
+ * Returns the user by given username.
+ *
+ * @param string $username The username.
+ *
+ * @return User
+ *
+ * @throws UsernameNotFoundException If user whose given username does not exist.
+ */
+ private function getUser($username)
+ {
+ if (!isset($this->users[strtolower($username)])) {
+ $ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
+ $ex->setUsername($username);
+
+ throw $ex;
+ }
+
+ return $this->users[strtolower($username)];
+ }
}