35 lines
796 B
PHP
35 lines
796 B
PHP
<?php
|
||
|
||
namespace App\Http\Requests\Auth;
|
||
|
||
use App\Rules\PasswordNotReused;
|
||
use App\Support\PasswordPolicy;
|
||
use Illuminate\Foundation\Http\FormRequest;
|
||
|
||
/**
|
||
* Смена пароля с проверкой политики и истории (меры ИАФ.3).
|
||
*/
|
||
class ChangePasswordRequest extends FormRequest
|
||
{
|
||
public function authorize(): bool
|
||
{
|
||
return $this->user() !== null;
|
||
}
|
||
|
||
/**
|
||
* @return array<string, mixed>
|
||
*/
|
||
public function rules(): array
|
||
{
|
||
return [
|
||
'current_password' => ['required', 'current_password'],
|
||
'password' => [
|
||
'required',
|
||
'confirmed',
|
||
PasswordPolicy::rule(),
|
||
new PasswordNotReused($this->user()),
|
||
],
|
||
];
|
||
}
|
||
}
|