Improve exception thrown when user does not exists
User not found is not a RuntimeException. It must be a NotFoundException
This commit is contained in:
@ -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