From 6934747a6a6f1f805e04ea4c5751efb8e81f7d73 Mon Sep 17 00:00:00 2001 From: Gerben Oolbekkink Date: Mon, 18 Jan 2021 17:47:55 +0100 Subject: [PATCH] bug symfony/symfony#39878 [doctrine-bridge] Add username to UserNameNotFoundException --- Provider/GuardAuthenticationProvider.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) {