@@ -61,29 +61,29 @@ public function getUserIdentifier(): string
6161 */
6262 public function getUser (): UserInterface
6363 {
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+ }
6867
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+ }
7071
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 );
7573
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 );
7878
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+ }
8281
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 )));
8484 }
8585
86- return $ this ->user ;
86+ return $ this ->user = $ user ;
8787 }
8888
8989 public function getUserLoader (): ?callable
0 commit comments