feat: update password
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdatePasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'current_password' => ['required', 'string', 'current_password:sanctum'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed', 'different:current_password'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('currentPassword') && ! $this->has('current_password')) {
|
||||
$this->merge([
|
||||
'current_password' => $this->input('currentPassword'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->has('passwordConfirmation') && ! $this->has('password_confirmation')) {
|
||||
$this->merge([
|
||||
'password_confirmation' => $this->input('passwordConfirmation'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user