feat: update password

This commit is contained in:
2026-05-26 13:48:22 +02:00
parent 835dfcc677
commit b3968a8181
6 changed files with 138 additions and 1 deletions
@@ -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'),
]);
}
}
}