|
8 | 8 | use Carbon\Carbon; |
9 | 9 | use October\Rain\Auth\Models\User as UserBase; |
10 | 10 | use RainLab\User\Models\Settings as UserSettings; |
| 11 | +use Illuminate\Validation\Rules\Password as PasswordRule; |
11 | 12 | use October\Rain\Auth\AuthException; |
12 | 13 |
|
13 | 14 | class User extends UserBase |
@@ -274,31 +275,25 @@ public function beforeValidate() |
274 | 275 | * Apply rules Settings |
275 | 276 | */ |
276 | 277 | $minPasswordLength = Settings::get('min_password_length', static::getMinPasswordLength()); |
277 | | - if (class_exists('\Illuminate\Validation\Rules\Password')) { |
278 | | - $passwordRule = \Illuminate\Validation\Rules\Password::min($minPasswordLength); |
279 | | - if (Settings::get('require_mixed_case')) { |
280 | | - $passwordRule->mixedCase(); |
281 | | - } |
282 | | - |
283 | | - if (Settings::get('require_uncompromised')) { |
284 | | - $passwordRule->uncompromised(); |
285 | | - } |
286 | | - |
287 | | - if (Settings::get('require_number')) { |
288 | | - $passwordRule->numbers(); |
289 | | - } |
| 278 | + $passwordRule = PasswordRule::min($minPasswordLength); |
| 279 | + if (Settings::get('require_mixed_case')) { |
| 280 | + $passwordRule->mixedCase(); |
| 281 | + } |
290 | 282 |
|
291 | | - if (Settings::get('require_symbol')) { |
292 | | - $passwordRule->symbols(); |
293 | | - } |
| 283 | + if (Settings::get('require_uncompromised')) { |
| 284 | + $passwordRule->uncompromised(); |
| 285 | + } |
294 | 286 |
|
295 | | - $this->addValidationRule('password', $passwordRule); |
296 | | - $this->addValidationRule('password_confirmation', $passwordRule); |
| 287 | + if (Settings::get('require_number')) { |
| 288 | + $passwordRule->numbers(); |
297 | 289 | } |
298 | | - else { |
299 | | - $this->rules['password'] = "required:create|between:$minPasswordLength,255|confirmed"; |
300 | | - $this->rules['password_confirmation'] = "required_with:password|between:$minPasswordLength,255"; |
| 290 | + |
| 291 | + if (Settings::get('require_symbol')) { |
| 292 | + $passwordRule->symbols(); |
301 | 293 | } |
| 294 | + |
| 295 | + $this->addValidationRule('password', $passwordRule); |
| 296 | + $this->addValidationRule('password_confirmation', $passwordRule); |
302 | 297 | } |
303 | 298 |
|
304 | 299 | /** |
|
0 commit comments