2023-03-24 13:54:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Fortify;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
use Laravel\Fortify\Contracts\UpdatesUserPasswords;
|
|
|
|
|
|
|
|
class UpdateUserPassword implements UpdatesUserPasswords
|
|
|
|
{
|
|
|
|
use PasswordValidationRules;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validate and update the user's password.
|
|
|
|
*
|
2024-06-10 20:43:34 +00:00
|
|
|
* @param array<string, string> $input
|
2023-03-24 13:54:17 +00:00
|
|
|
*/
|
|
|
|
public function update(User $user, array $input): void
|
|
|
|
{
|
|
|
|
Validator::make($input, [
|
|
|
|
'current_password' => ['required', 'string', 'current_password:web'],
|
|
|
|
'password' => $this->passwordRules(),
|
|
|
|
], [
|
|
|
|
'current_password.current_password' => __('The provided password does not match your current password.'),
|
|
|
|
])->validateWithBag('updatePassword');
|
|
|
|
|
|
|
|
$user->forceFill([
|
|
|
|
'password' => Hash::make($input['password']),
|
|
|
|
])->save();
|
|
|
|
}
|
|
|
|
}
|