58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Rules\MatchCurrentPasswordRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class ChangePasswordRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Auth::check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'password' => ['required', 'confirmed', Password::min(8)
|
|
->mixedCase()
|
|
->numbers()
|
|
->symbols()],
|
|
'my_password' => ['required', Password::min(8)
|
|
->mixedCase()
|
|
->numbers()
|
|
->symbols(), new MatchCurrentPasswordRule],
|
|
];
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'password.required' => 'Password baru wajib diisi.',
|
|
'password.confirmed' => 'Konfirmasi password baru tidak cocok.',
|
|
'password.min' => 'Password baru harus memiliki minimal 8 karakter.',
|
|
'password.mixedCase' => 'Password baru harus mengandung huruf besar dan huruf kecil.',
|
|
'password.numbers' => 'Password baru harus mengandung angka.',
|
|
'password.symbols' => 'Password baru harus mengandung simbol.',
|
|
|
|
'my_password.required' => 'Password Anda wajib diisi.',
|
|
'my_password.confirmed' => 'Konfirmasi password Anda tidak cocok.',
|
|
'my_password.min' => 'Password Anda harus memiliki minimal 8 karakter.',
|
|
'my_password.mixedCase' => 'Password Anda harus mengandung huruf besar dan huruf kecil.',
|
|
'my_password.numbers' => 'Password Anda harus mengandung angka.',
|
|
'my_password.symbols' => 'Password Anda harus mengandung simbol.',
|
|
];
|
|
}
|
|
}
|