From b57411b5ec734c02451a9f7641d3b9d13bd838fb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 18 Dec 2010 08:15:13 +0100 Subject: [PATCH] renamed reloadUserByAccount() to loadUserByAccount() --- .../Bundle/DoctrineBundle/Security/EntityUserProvider.php | 2 +- .../Security/DocumentUserProvider.php | 2 +- .../HttpKernel/Security/Firewall/ContextListener.php | 7 ++++--- .../Authentication/Provider/DaoAuthenticationProvider.php | 2 +- .../Provider/UserAuthenticationProvider.php | 4 ++-- .../Component/Security/User/InMemoryUserProvider.php | 2 +- .../Component/Security/User/UserProviderInterface.php | 8 +++++--- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Bundle/DoctrineBundle/Security/EntityUserProvider.php b/src/Symfony/Bundle/DoctrineBundle/Security/EntityUserProvider.php index 97d8a09f2ffd..8aeb058e98e4 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Security/EntityUserProvider.php +++ b/src/Symfony/Bundle/DoctrineBundle/Security/EntityUserProvider.php @@ -45,7 +45,7 @@ public function loadUserByUsername($username) /** * {@inheritDoc} */ - public function reloadUserByAccount(AccountInterface $account) + public function loadUserByAccount(AccountInterface $account) { if (!$account instanceof $this->class) { throw new UnsupportedAccountException(sprintf('Instances of "%s" are not supported.', get_class($account))); diff --git a/src/Symfony/Bundle/DoctrineMongoDBBundle/Security/DocumentUserProvider.php b/src/Symfony/Bundle/DoctrineMongoDBBundle/Security/DocumentUserProvider.php index 07f35bd1f7f3..ce05d27c6c53 100644 --- a/src/Symfony/Bundle/DoctrineMongoDBBundle/Security/DocumentUserProvider.php +++ b/src/Symfony/Bundle/DoctrineMongoDBBundle/Security/DocumentUserProvider.php @@ -45,7 +45,7 @@ public function loadUserByUsername($username) /** * {@inheritDoc} */ - public function reloadUserByAccount(AccountInterface $account) + public function loadUserByAccount(AccountInterface $account) { if (!$account instanceof $this->class) { throw new UnsupportedAccountException(sprintf('Instances of "%s" are not supported.', get_class($account))); diff --git a/src/Symfony/Component/HttpKernel/Security/Firewall/ContextListener.php b/src/Symfony/Component/HttpKernel/Security/Firewall/ContextListener.php index fcaafed4400b..60016fc86313 100644 --- a/src/Symfony/Component/HttpKernel/Security/Firewall/ContextListener.php +++ b/src/Symfony/Component/HttpKernel/Security/Firewall/ContextListener.php @@ -123,6 +123,7 @@ public function write(Event $event, Response $response) * Refreshes the user by reloading it from the user provider * * @param TokenInterface $token + * * @return TokenInterface|null */ protected function refreshUser(TokenInterface $token) @@ -138,7 +139,7 @@ protected function refreshUser(TokenInterface $token) foreach ($this->userProviders as $provider) { try { - $cUser = $provider->reloadUserByAccount($user); + $cUser = $provider->loadUserByAccount($user); $token->setRoles($cUser->getRoles()); $token->setUser($cUser); @@ -149,12 +150,12 @@ protected function refreshUser(TokenInterface $token) return $token; } catch (UnsupportedAccountException $unsupported) { + // let's try the next user provider } catch (UsernameNotFoundException $notFound) { - return null; } } throw new \RuntimeException(sprintf('There is no user provider for user "%s".', get_class($user))); } -} \ No newline at end of file +} diff --git a/src/Symfony/Component/Security/Authentication/Provider/DaoAuthenticationProvider.php b/src/Symfony/Component/Security/Authentication/Provider/DaoAuthenticationProvider.php index 4f9344032047..eaf3242ce091 100644 --- a/src/Symfony/Component/Security/Authentication/Provider/DaoAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Authentication/Provider/DaoAuthenticationProvider.php @@ -87,7 +87,7 @@ protected function retrieveUser($username, UsernamePasswordToken $token) if (!$user instanceof AccountInterface) { throw new AuthenticationServiceException('The user provider must return an AccountInterface object.'); } - + return $user; } catch (UsernameNotFoundException $notFound) { throw $notFound; diff --git a/src/Symfony/Component/Security/Authentication/Provider/UserAuthenticationProvider.php b/src/Symfony/Component/Security/Authentication/Provider/UserAuthenticationProvider.php index b5e2dbbf3b69..0ded6f7f9a4f 100644 --- a/src/Symfony/Component/Security/Authentication/Provider/UserAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Authentication/Provider/UserAuthenticationProvider.php @@ -59,11 +59,11 @@ public function authenticate(TokenInterface $token) if (!$user instanceof AccountInterface) { throw new AuthenticationServiceException('retrieveUser() must return an AccountInterface.'); } - + $this->accountChecker->checkPreAuth($user); $this->checkAuthentication($user, $token); $this->accountChecker->checkPostAuth($user); - + return new UsernamePasswordToken($user, $token->getCredentials(), $user->getRoles()); } catch (UsernameNotFoundException $notFound) { if ($this->hideUserNotFoundExceptions) { diff --git a/src/Symfony/Component/Security/User/InMemoryUserProvider.php b/src/Symfony/Component/Security/User/InMemoryUserProvider.php index fe9dc30e8d94..566d2a83566d 100644 --- a/src/Symfony/Component/Security/User/InMemoryUserProvider.php +++ b/src/Symfony/Component/Security/User/InMemoryUserProvider.php @@ -79,7 +79,7 @@ public function loadUserByUsername($username) /** * {@inheritDoc} */ - public function reloadUserByAccount(AccountInterface $account) + public function loadUserByAccount(AccountInterface $account) { if (!$account instanceof User) { throw new UnsupportedAccountException(sprintf('Instances of "%s" are not supported.', get_class($account))); diff --git a/src/Symfony/Component/Security/User/UserProviderInterface.php b/src/Symfony/Component/Security/User/UserProviderInterface.php index 511197a92070..ac7e470f52fc 100644 --- a/src/Symfony/Component/Security/User/UserProviderInterface.php +++ b/src/Symfony/Component/Security/User/UserProviderInterface.php @@ -27,20 +27,22 @@ interface UserProviderInterface * * @throws UsernameNotFoundException if the user is not found * @param string $username The username + * * @return AccountInterface */ function loadUserByUsername($username); /** * Loads the user for the account interface. - * + * * It is up to the implementation if it decides to reload the user data * from the database, or if it simply merges the passed User into the * identity map of an entity manager. - * + * * @throws UnsupportedAccountException if the account is not supported * @param AccountInterface $user + * * @return AccountInterface */ - function reloadUserByAccount(AccountInterface $user); + function loadUserByAccount(AccountInterface $user); } \ No newline at end of file