@@ -133,21 +133,7 @@ Here's an example of how this might look::
133
133
{
134
134
public function loadUserByUsername($username)
135
135
{
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);
151
137
}
152
138
153
139
public function refreshUser(UserInterface $user)
@@ -158,13 +144,32 @@ Here's an example of how this might look::
158
144
);
159
145
}
160
146
161
- return $this->loadUserByUsername($user->getUsername() );
147
+ return $this->fetchUser($username );
162
148
}
163
149
164
150
public function supportsClass($class)
165
151
{
166
152
return WebserviceUser::class === $class;
167
153
}
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
+ }
168
173
}
169
174
170
175
Create a Service for the User Provider
0 commit comments