Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| AdminSetPasswordService | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setPassword | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Services\Admin\Users; |
| 4 | |
| 5 | use App\Http\Models\Auth\User; |
| 6 | use App\Http\Repositories\UserRepository; |
| 7 | |
| 8 | /** |
| 9 | * Service for force-setting a user's password without requiring the old password. |
| 10 | * |
| 11 | * This operation is restricted to VENGRESO_ADMIN users only and bypasses the |
| 12 | * standard password-change flow (which requires the current password). |
| 13 | */ |
| 14 | class AdminSetPasswordService |
| 15 | { |
| 16 | public function __construct( |
| 17 | private UserRepository $userRepository |
| 18 | ) {} |
| 19 | |
| 20 | /** |
| 21 | * Force-set a new password for the given user. |
| 22 | * |
| 23 | * The password will be hashed before persisting. No old-password verification |
| 24 | * is performed — caller must ensure the request is admin-authorised. |
| 25 | * |
| 26 | * @param User $user The target user |
| 27 | * @param string $password The new plain-text password |
| 28 | */ |
| 29 | public function setPassword(User $user, string $password): void |
| 30 | { |
| 31 | $this->userRepository->setPassword($user, $password); |
| 32 | } |
| 33 | } |