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