Added a new feature to allow users to update their passwords.

This commit is contained in:
2023-07-07 18:08:14 +06:00
parent 00a0624eea
commit 39eae7f196
7 changed files with 73 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Services\Private;
use App\Dto\Request\Private\Profile\Update;
use App\Dto\Request\Private\Profile\UpdatePassword;
use App\Models\User;
use App\ServiceResults\ServiceResultError;
use App\ServiceResults\ServiceResultSuccess;
@@ -28,4 +29,15 @@ final class ProfileService extends Service
}
return $this->ok(__('Profile saved successfully'));
}
public function updatePassword(UpdatePassword $update, User $user): ServiceResultError | ServiceResultSuccess
{
try {
$this->userCommandHandler->handleUpdatePassword($user, $update->getPassword());
} catch (\Throwable $e) {
report($e->getMessage());
return $this->errService($e->getMessage());
}
return $this->ok(__('The password has been changed'));
}
}