37 lines
939 B
PHP
37 lines
939 B
PHP
<?php
|
|
|
|
namespace App\Actions\Fortify;
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
|
|
|
class ResetUserPassword implements ResetsUserPasswords
|
|
{
|
|
use PasswordValidationRules;
|
|
|
|
/**
|
|
* Validate and reset the user's forgotten password.
|
|
*
|
|
* @param mixed $user
|
|
* @param array $input
|
|
* @return void
|
|
*/
|
|
public function reset($user, array $input)
|
|
{
|
|
if (!empty($user->password_change_disabled)) {
|
|
throw \Illuminate\Validation\ValidationException::withMessages([
|
|
'password' => [__('Password changes are disabled for this account.')],
|
|
]);
|
|
}
|
|
|
|
Validator::make($input, [
|
|
'password' => $this->passwordRules(),
|
|
])->validate();
|
|
|
|
$user->forceFill([
|
|
'password' => Hash::make($input['password']),
|
|
])->save();
|
|
}
|
|
}
|