8000 [2.2] make refreshUser try all providers fixes #4498 · Pull Request #4778 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.2] make refreshUser try all providers fixes #4498 #4778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix for issue 4498
Make refreshUser try all user providers instead stopping at the first
UserNotFound exception.
  • Loading branch information
SeriousKen committed Jul 7, 2012
commit cc69b345a0601932ca87da406b3c61cd4ffaa85b
15 changes: 11 additions & 4 deletions src/Symfony/Component/Security/Http/Firewall/ContextListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ private function refreshUser(TokenInterface $token)
$this->logger->debug(sprintf('Reloading user from user provider.'));
}

$supportedUserFound = false;

foreach ($this->userProviders as $provider) {
try {
$token->setUser($provider->refreshUser($user));
Expand All @@ -150,12 +152,17 @@ private function refreshUser(TokenInterface $token)
} catch (UnsupportedUserException $unsupported) {
// let's try the next user provider
} catch (UsernameNotFoundException $notFound) {
if (null !== $this->logger) {
$this->logger->warn(sprintf('Username "%s" could not be found.', $user->getUsername()));
}
$supportedUserFound = true;
// let's try the next user provider
}
}

return null;
if ($supportedUserFound) {
if (null !== $this->logger) {
$this->logger->warn(sprintf('Username "%s" could not be found.', $user->getUsername()));
}

return null;
}

throw new \RuntimeException(sprintf('There is no user provider for user "%s".', get_class($user)));
Expand Down
0