Skip to content

Commit

Permalink
Merge pull request #552 from Eseperio/patch-6
Browse files Browse the repository at this point in the history
Improve exception thrown when user does not exists
  • Loading branch information
maxxer authored May 15, 2024
2 parents c5a1e9b + 6c220fb commit 3633402
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## dev

- Enh: Changed exception thrown in PasswordRecoveryService from `RuntimeException` to `NotFoundException`. (eseperio)

## 1.6.3 Mar 18th, 2024

- Fix: Update last_login_at and last_login_ip on social networt authenticate (e.luhr)
Expand Down
3 changes: 2 additions & 1 deletion src/User/Service/PasswordRecoveryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Da\User\Traits\ModuleAwareTrait;
use Exception;
use Yii;
use yii\web\NotFoundHttpException;

class PasswordRecoveryService implements ServiceInterface
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3633402

Please sign in to comment.