diff --git a/src/User/Service/PasswordRecoveryService.php b/src/User/Service/PasswordRecoveryService.php index 9d6e2db6..41bcce3b 100644 --- a/src/User/Service/PasswordRecoveryService.php +++ b/src/User/Service/PasswordRecoveryService.php @@ -41,18 +41,13 @@ public function __construct($email, MailService $mailService, UserQuery $query) public function run() { try { - if ($this->getModule()->enableFlashMessages == true) { - Yii::$app->session->setFlash( - 'info', - Yii::t('usuario', 'An email with instructions to create a new password has been sent to {email} if it is associated with an {appName} account. Your existing password has not been changed.', ['email' => $this->email, 'appName' => Yii::$app->name]) - ); - } /** @var User $user */ $user = $this->query->whereEmail($this->email)->one(); if ($user === null) { - throw new \RuntimeException('User not found.'); + Yii::$app->session->setFlash('error', Yii::t('usuario', 'User not found.')); + return false; } $token = TokenFactory::makeRecoveryToken($user->id); @@ -67,6 +62,12 @@ public function run() return false; } + if ($this->getModule()->enableFlashMessages == true) { + Yii::$app->session->setFlash( + 'info', + Yii::t('usuario', 'An email with instructions to create a new password has been sent to {email} if it is associated with an {appName} account. Your existing password has not been changed.', ['email' => $this->email, 'appName' => Yii::$app->name]) + ); + } return true; } catch (Exception $e) { Yii::error($e->getMessage(), 'usuario');