@@ -133,21 +133,7 @@ Here's an example of how this might look::
133133 {
134134 public function loadUserByUsername($username)
135135 {
136- // make a call to your webservice here
137- $userData = ...
138- // pretend it returns an array on success, false if there is no user
139-
140- if ($userData) {
141- $password = '...';
142-
143- // ...
144-
145- return new WebserviceUser($username, $password, $salt, $roles);
146- }
147-
148- throw new UsernameNotFoundException(
149- sprintf('Username "%s" does not exist.', $username)
150- );
136+ return $this->fetchUser($username);
151137 }
152138
153139 public function refreshUser(UserInterface $user)
@@ -158,13 +144,32 @@ Here's an example of how this might look::
158144 );
159145 }
160146
161- return $this->loadUserByUsername($user->getUsername() );
147+ return $this->fetchUser($username );
162148 }
163149
164150 public function supportsClass($class)
165151 {
166152 return WebserviceUser::class === $class;
167153 }
154+
155+ private function fetchUser($username)
156+ {
157+ // make a call to your webservice here
158+ $userData = ...
159+ // pretend it returns an array on success, false if there is no user
160+
161+ if ($userData) {
162+ $password = '...';
163+
164+ // ...
165+
166+ return new WebserviceUser($username, $password, $salt, $roles);
167+ }
168+
169+ throw new UsernameNotFoundException(
170+ sprintf('Username "%s" does not exist.', $username)
171+ );
172+ }
168173 }
169174
170175Create a Service for the User Provider
0 commit comments