File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Ggbb \SymfonyUserPermission \Exception ;
4
+
5
+ use Symfony \Component \Security \Core \Exception \AuthenticationException ;
6
+
7
+ class AuthenticationUserNotFoundException extends AuthenticationException
8
+ {
9
+ public function getMessageKey (): string
10
+ {
11
+ return 'User not found ' ;
12
+ }
13
+ }
Original file line number Diff line number Diff line change 3
3
namespace Ggbb \SymfonyUserPermission \Security \Provider ;
4
4
5
5
use Doctrine \ORM \EntityManagerInterface ;
6
+ use Ggbb \SymfonyUserPermission \Exception \AuthenticationUserNotFoundException ;
6
7
use Ggbb \SymfonyUserPermission \GgbbUserPermissionBundle ;
7
8
use Symfony \Bridge \Doctrine \Security \User \UserLoaderInterface ;
8
9
use Symfony \Component \DependencyInjection \ParameterBag \ContainerBagInterface ;
@@ -24,7 +25,12 @@ public function loadUserByIdentifier(string $identifier): UserInterface
24
25
/** @var UserLoaderInterface $userRepository */
25
26
$ userRepository = $ this ->entityManager ->getRepository ($ userName );
26
27
27
- return $ userRepository ->loadUserByIdentifier ($ identifier );
28
+ $ user = $ userRepository ->loadUserByIdentifier ($ identifier );
29
+ if (!$ user ) {
30
+ throw new AuthenticationUserNotFoundException ();
31
+ }
32
+
33
+ return $ user ;
28
34
}
29
35
30
36
public function refreshUser (UserInterface $ user ): UserInterface
You can’t perform that action at this time.
0 commit comments