Skip to content

Commit 3e352b7

Browse files
damienfafabpot
authored andcommitted
Fix issue 45070 : UserNotFoundException is not thrown
See symfony/symfony#45070.
1 parent 714e3de commit 3e352b7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Authenticator/Passport/Badge/UserBadge.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1515
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
16+
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
1617
use Symfony\Component\Security\Core\User\UserInterface;
1718
use Symfony\Component\Security\Http\EventListener\UserProviderListener;
1819

@@ -66,6 +67,15 @@ public function getUser(): UserInterface
6667
}
6768

6869
$user = ($this->userLoader)($this->userIdentifier);
70+
71+
// No user has been found via the $this->userLoader callback
72+
if (null === $user) {
73+
$exception = new UserNotFoundException();
74+
$exception->setUserIdentifier($this->userIdentifier);
75+
76+
throw $exception;
77+
}
78+
6979
if (!$user instanceof UserInterface) {
7080
throw new AuthenticationServiceException(sprintf('The user provider must return a UserInterface object, "%s" given.', get_debug_type($this->user)));
7181
}

0 commit comments

Comments
 (0)