Merge pull request #552 from Eseperio/patch-6
Improve exception thrown when user does not exists
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## dev
|
||||||
|
|
||||||
|
- Enh: Changed exception thrown in PasswordRecoveryService from `RuntimeException` to `NotFoundException`. (eseperio)
|
||||||
|
|
||||||
## 1.6.3 Mar 18th, 2024
|
## 1.6.3 Mar 18th, 2024
|
||||||
|
|
||||||
- Fix: Update last_login_at and last_login_ip on social networt authenticate (e.luhr)
|
- Fix: Update last_login_at and last_login_ip on social networt authenticate (e.luhr)
|
||||||
|
|||||||
@ -19,6 +19,7 @@ use Da\User\Traits\MailAwareTrait;
|
|||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
class PasswordRecoveryService implements ServiceInterface
|
class PasswordRecoveryService implements ServiceInterface
|
||||||
{
|
{
|
||||||
@ -50,7 +51,7 @@ class PasswordRecoveryService implements ServiceInterface
|
|||||||
$user = $this->query->whereEmail($this->email)->one();
|
$user = $this->query->whereEmail($this->email)->one();
|
||||||
|
|
||||||
if ($user === null) {
|
if ($user === null) {
|
||||||
throw new \RuntimeException('User not found.');
|
throw new NotFoundHttpException(Yii::t('usuario', 'User not found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$token = TokenFactory::makeRecoveryToken($user->id);
|
$token = TokenFactory::makeRecoveryToken($user->id);
|
||||||
|
|||||||
Reference in New Issue
Block a user