@@ -61,29 +61,29 @@ public function getUserIdentifier(): string
61
61
*/
62
62
public function getUser (): UserInterface
63
63
{
64
- if (!isset ($ this ->user )) {
65
- if (null === $ this ->userLoader ) {
66
- throw new \LogicException (sprintf ('No user loader is configured, did you forget to register the "%s" listener? ' , UserProviderListener::class));
67
- }
64
+ if (null !== $ this ->user ) {
65
+ return $ this ->user ;
66
+ }
68
67
69
- $ user = ($ this ->userLoader )($ this ->userIdentifier );
68
+ if (null === $ this ->userLoader ) {
69
+ throw new \LogicException (sprintf ('No user loader is configured, did you forget to register the "%s" listener? ' , UserProviderListener::class));
70
+ }
70
71
71
- // No user has been found via the $this->userLoader callback
72
- if (null === $ user ) {
73
- $ exception = new UserNotFoundException ();
74
- $ exception ->setUserIdentifier ($ this ->userIdentifier );
72
+ $ user = ($ this ->userLoader )($ this ->userIdentifier );
75
73
76
- throw $ exception ;
77
- }
74
+ // No user has been found via the $this->userLoader callback
75
+ if (null === $ user ) {
76
+ $ exception = new UserNotFoundException ();
77
+ $ exception ->setUserIdentifier ($ this ->userIdentifier );
78
78
79
- if (!$ user instanceof UserInterface) {
80
- throw new AuthenticationServiceException (sprintf ('The user provider must return a UserInterface object, "%s" given. ' , get_debug_type ($ this ->user )));
81
- }
79
+ throw $ exception ;
80
+ }
82
81
83
- $ this ->user = $ user ;
82
+ if (!$ user instanceof UserInterface) {
83
+ throw new AuthenticationServiceException (sprintf ('The user provider must return a UserInterface object, "%s" given. ' , get_debug_type ($ user )));
84
84
}
85
85
86
- return $ this ->user ;
86
+ return $ this ->user = $ user ;
87
87
}
88
88
89
89
public function getUserLoader (): ?callable
0 commit comments