From 1b11cb98c5eb9fd22248aff2693251da7993293d Mon Sep 17 00:00:00 2001 From: "E.Alamo" Date: Wed, 15 May 2024 09:14:28 +0200 Subject: [PATCH 1/3] Improve exception thrown when user does not exists User not found is not a RuntimeException. It must be a NotFoundException --- src/User/Service/PasswordRecoveryService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/User/Service/PasswordRecoveryService.php b/src/User/Service/PasswordRecoveryService.php index 0e5b5978..a9e388ac 100644 --- a/src/User/Service/PasswordRecoveryService.php +++ b/src/User/Service/PasswordRecoveryService.php @@ -19,6 +19,7 @@ use Da\User\Traits\ModuleAwareTrait; use Exception; use Yii; +use yii\web\NotFoundHttpException; class PasswordRecoveryService implements ServiceInterface { @@ -50,7 +51,7 @@ public function run() $user = $this->query->whereEmail($this->email)->one(); if ($user === null) { - throw new \RuntimeException('User not found.'); + throw new NotFoundHttpException(Yii::t('usuario', 'User not found')); } $token = TokenFactory::makeRecoveryToken($user->id); From 3a30580e350b1ab77fb1990c1c71aca21d240a45 Mon Sep 17 00:00:00 2001 From: "E.Alamo" Date: Wed, 15 May 2024 10:38:25 +0200 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cebe7c3..7ef51322 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # CHANGELOG +## 1.6.4 May 15th, 2024 + +- Enh: Changed exception thrown in PasswordRecoveryService from `RuntimeException` to `NotFoundException`. (eseperio) ## 1.6.3 Mar 18th, 2024 From 6c220fb78bff245697a863cd7077618a1a356f3f Mon Sep 17 00:00:00 2001 From: Lorenzo Milesi Date: Wed, 15 May 2024 11:08:48 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ef51322..9197825c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # CHANGELOG -## 1.6.4 May 15th, 2024 + +## dev - Enh: Changed exception thrown in PasswordRecoveryService from `RuntimeException` to `NotFoundException`. (eseperio)