Skip to content

Commit a110818

Browse files
fabpotnicolas-grekas
authored andcommitted
bug #45452 [Security] Fix UserNotFoundException is not thrown (damienfa)
This PR was merged into the 5.4 branch. Discussion ---------- [Security] Fix UserNotFoundException is not thrown | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #45070 | License | MIT | Doc PR | N/A Commits ------- 7e0ed85d9a Fix issue 45070 : UserNotFoundException is not thrown
1 parent 28bf15c commit a110818

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

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

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

0 commit comments

Comments
 (0)