Jelajahi Sumber

Search in others user providers when a user is not found in the first user provider and throws the right exception.

Abhoryo 13 tahun lalu
induk
melakukan
3a64b08bd9

+ 10 - 2
src/Symfony/Component/Security/Core/User/ChainUserProvider.php

@@ -52,15 +52,23 @@ class ChainUserProvider implements UserProviderInterface
      */
     public function refreshUser(UserInterface $user)
     {
+        $supportedUserFound = false;
+
         foreach ($this->providers as $provider) {
             try {
                 return $provider->refreshUser($user);
             } catch (UnsupportedUserException $unsupported) {
                 // try next one
+            } catch (UsernameNotFoundException $notFound) {
+                // try next one
+                $supportedUserFound = true;
             }
         }
-
-        throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
+        
+        if ($supportedUserFound)
+            throw new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
+        else
+            throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
     }
 
     /**