|
20 | 20 | use Illuminate\Support\Facades\Hash;
|
21 | 21 | use Illuminate\Support\Str;
|
22 | 22 | use Illuminate\Support\Traits\Macroable;
|
| 23 | +use InvalidArgumentException; |
23 | 24 | use RuntimeException;
|
24 | 25 | use Symfony\Component\HttpFoundation\Request;
|
25 | 26 | use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
@@ -573,26 +574,6 @@ protected function cycleRememberToken(AuthenticatableContract $user)
|
573 | 574 | $this->provider->updateRememberToken($user, $token);
|
574 | 575 | }
|
575 | 576 |
|
576 |
| - /** |
577 |
| - * Rehash the current user's password. |
578 |
| - * |
579 |
| - * @param string $password |
580 |
| - * @param string $attribute |
581 |
| - * @return bool|null |
582 |
| - * |
583 |
| - * @throws \Illuminate\Auth\AuthenticationException |
584 |
| - */ |
585 |
| - protected function rehashUserPassword($password, $attribute) |
586 |
| - { |
587 |
| - if (! Hash::check($password, $this->user()->$attribute)) { |
588 |
| - throw new AuthenticationException('Password mismatch.'); |
589 |
| - } |
590 |
| - |
591 |
| - return tap($this->user()->forceFill([ |
592 |
| - $attribute => Hash::make($password), |
593 |
| - ]))->save(); |
594 |
| - } |
595 |
| - |
596 | 577 | /**
|
597 | 578 | * Invalidate other sessions for the current user.
|
598 | 579 | *
|
@@ -622,6 +603,26 @@ public function logoutOtherDevices($password, $attribute = 'password')
|
622 | 603 | return $result;
|
623 | 604 | }
|
624 | 605 |
|
| 606 | + /** |
| 607 | + * Rehash the current user's password. |
| 608 | + * |
| 609 | + * @param string $password |
| 610 | + * @param string $attribute |
| 611 | + * @return bool|null |
| 612 | + * |
| 613 | + * @throws \InvalidArgumentException |
| 614 | + */ |
| 615 | + protected function rehashUserPassword($password, $attribute) |
| 616 | + { |
| 617 | + if (! Hash::check($password, $this->user()->{$attribute})) { |
| 618 | + throw new InvalidArgumentException("The given password does not match the current password."); |
| 619 | + } |
| 620 | + |
| 621 | + return tap($this->user()->forceFill([ |
| 622 | + $attribute => Hash::make($password), |
| 623 | + ]))->save(); |
| 624 | + } |
| 625 | + |
625 | 626 | /**
|
626 | 627 | * Register an authentication attempt event listener.
|
627 | 628 | *
|
|
0 commit comments