|
16 | 16 |
|
17 | 17 | use Authentication\AuthenticationServiceInterface; |
18 | 18 | use Authentication\Authenticator\ResultInterface; |
| 19 | +use Authentication\Identifier\IdentifierCollection; |
19 | 20 | use Cake\Controller\Component; |
20 | 21 | use Cake\Core\Configure; |
21 | 22 | use Cake\Datasource\EntityInterface; |
@@ -195,25 +196,37 @@ protected function handlePasswordRehash($service, $user, \Cake\Http\ServerReques |
195 | 196 | $identifiersNames = (array)Configure::read('Auth.PasswordRehash.identifiers'); |
196 | 197 | foreach ($identifiersNames as $identifierName) { |
197 | 198 | if (!$service->identifiers()->has($identifierName)) { |
| 199 | + Log::warning("Error saving user id $user->id password after rehashing: identifier $identifierName not found. Check your Auth.PasswordRehash.identifiers configuration."); |
198 | 200 | continue; |
199 | 201 | } |
200 | 202 | /** |
201 | 203 | * @var \Authentication\Identifier\AbstractIdentifier|null $checker |
202 | 204 | */ |
203 | 205 | $checker = $service->identifiers()->get($identifierName); |
204 | 206 | $this->saveRehashedPassword($checker, $request, $user); |
205 | | - break; |
206 | 207 | } |
207 | 208 |
|
208 | 209 | // new way to define identifiers, inside the authenticators |
209 | 210 | $authenticatorNames = (array)Configure::read('Auth.PasswordRehash.authenticators'); |
210 | | - foreach ($authenticatorNames as $authenticatorName) { |
| 211 | + foreach ($authenticatorNames as $authenticatorName => $identifierName) { |
| 212 | + if (!$service->authenticators()->has($authenticatorName)) { |
| 213 | + Log::warning("Error saving user id $user->id password after rehashing: authenticator $authenticatorName not found. Check your Auth.PasswordRehash.authenticators configuration."); |
| 214 | + continue; |
| 215 | + } |
| 216 | + /** |
| 217 | + * @var IdentifierCollection $identifierCollection |
| 218 | + */ |
| 219 | + $identifierCollection = $service->authenticators()->get($authenticatorName)->getIdentifier(); |
| 220 | + if (!$identifierCollection->has($identifierName)) { |
| 221 | + Log::warning("Error saving user id $user->id password after rehashing: identifier $identifierName not found. Check your Auth.PasswordRehash.authenticators configuration."); |
| 222 | + continue; |
| 223 | + } |
| 224 | + |
211 | 225 | /** |
212 | 226 | * @var \Authentication\Identifier\AbstractIdentifier|null $checker |
213 | 227 | */ |
214 | | - $checker = $service->authenticators()->get($authenticatorName)->getIdentifier(); |
| 228 | + $checker = $identifierCollection->get($identifierName); |
215 | 229 | $this->saveRehashedPassword($checker, $request, $user); |
216 | | - break; |
217 | 230 | } |
218 | 231 | } |
219 | 232 |
|
|
0 commit comments