74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Club\Customers;
|
|
|
|
use App\Rules\CrmCustomerPassword;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class UpdatePasswordRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return auth('club')->check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
/** @var \LDC\LDCCRM\Models\Customer $crmCustomer */
|
|
$crmCustomer = \auth('club')->user()->api_data;
|
|
return [
|
|
'old_password' => [
|
|
'required',
|
|
new CrmCustomerPassword($crmCustomer)
|
|
],
|
|
'password' => [
|
|
'required',
|
|
'string',
|
|
'confirmed',
|
|
Password::min(8)->max(255)->mixedCase()->letters()->numbers()->uncompromised()
|
|
]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'old_password' => trans('validation.custom.old_password'),
|
|
'password' => trans('validation.attributes.password'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom messages for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'password.max' => trans('255 caractères maximum'),
|
|
'password.min' => trans('8 caractères minimum'),
|
|
'password.letters' => trans('Au moins une lettre'),
|
|
'password.numbers' => trans('Au moins un chiffre'),
|
|
'password.mixed' => trans('Au moins une lettre majuscule et une lettre minuscule'),
|
|
'password.uncompromised' => trans('Ne doît pas être compromis'),
|
|
'password.confirmed' => trans('La confirmation doît correspondre au nouveau'),
|
|
];
|
|
}
|
|
}
|