diff --git a/Provider/GuardAuthenticationProvider.php b/Provider/GuardAuthenticationProvider.php index a34c2db..3467a32 100644 --- a/Provider/GuardAuthenticationProvider.php +++ b/Provider/GuardAuthenticationProvider.php @@ -105,7 +105,10 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator $user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider); if (null === $user) { - throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator))); + $e = new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator))); + $e->setUsername($token->getUsername()); + + throw $e; } if (!$user instanceof UserInterface) {