diff options
author | Johannes Schmitt <schmittjoh@gmail.com> | 2010-12-16 22:27:16 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2010-12-18 08:10:53 +0100 |
commit | 31f146e12fa9b03f083d1f31b1eca0f0dd9c5b3d (patch) | |
tree | 7f64999a11c9ce8cd9de91669fa597a390c369bd /Authentication/Provider | |
parent | a77e6b5f60bd1dac4d7ba19a900d72ae45d9fe26 (diff) | |
download | symfony-security-31f146e12fa9b03f083d1f31b1eca0f0dd9c5b3d.zip symfony-security-31f146e12fa9b03f083d1f31b1eca0f0dd9c5b3d.tar.gz symfony-security-31f146e12fa9b03f083d1f31b1eca0f0dd9c5b3d.tar.bz2 |
remove user provider name
Diffstat (limited to 'Authentication/Provider')
-rw-r--r-- | Authentication/Provider/DaoAuthenticationProvider.php | 23 | ||||
-rw-r--r-- | Authentication/Provider/UserAuthenticationProvider.php | 23 |
2 files changed, 19 insertions, 27 deletions
diff --git a/Authentication/Provider/DaoAuthenticationProvider.php b/Authentication/Provider/DaoAuthenticationProvider.php index 34880b2..4f93440 100644 --- a/Authentication/Provider/DaoAuthenticationProvider.php +++ b/Authentication/Provider/DaoAuthenticationProvider.php @@ -78,28 +78,21 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider { $user = $token->getUser(); if ($user instanceof AccountInterface) { - return array($user, $token->getUserProviderName()); + return $user; } - $result = null; try { - $result = $this->userProvider->loadUserByUsername($username); + $user = $this->userProvider->loadUserByUsername($username); + + if (!$user instanceof AccountInterface) { + throw new AuthenticationServiceException('The user provider must return an AccountInterface object.'); + } + + return $user; } catch (UsernameNotFoundException $notFound) { throw $notFound; } catch (\Exception $repositoryProblem) { throw new AuthenticationServiceException($repositoryProblem->getMessage(), $token, 0, $repositoryProblem); } - - if (!is_array($result) || 2 !== count($result)) { - throw new AuthenticationServiceException('User provider did not return an array, or array had invalid format.'); - } - if (!$result[0] instanceof AccountInterface) { - throw new AuthenticationServiceException('The user provider must return an AccountInterface object.'); - } - if (empty($result[1])) { - throw new AuthenticationServiceException('The user provider must return a non-empty user provider name.'); - } - - return $result; } } diff --git a/Authentication/Provider/UserAuthenticationProvider.php b/Authentication/Provider/UserAuthenticationProvider.php index f621e42..b5e2dbb 100644 --- a/Authentication/Provider/UserAuthenticationProvider.php +++ b/Authentication/Provider/UserAuthenticationProvider.php @@ -54,7 +54,17 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter $username = null === $token->getUser() ? 'NONE_PROVIDED' : (string) $token; try { - $result = $this->retrieveUser($username, $token); + $user = $this->retrieveUser($username, $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) { throw new BadCredentialsException('Bad credentials', 0, $notFound); @@ -62,17 +72,6 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter throw $notFound; } - - if (!is_array($result) || 2 !== count($result)) { - throw new AuthenticationServiceException('retrieveUser() did not return an array, or array had invalid format.'); - } - list($user, $userProviderName) = $result; - - $this->accountChecker->checkPreAuth($user); - $this->checkAuthentication($user, $token); - $this->accountChecker->checkPostAuth($user); - - return new UsernamePasswordToken($user, $token->getCredentials(), $userProviderName, $user->getRoles()); } /** |