From 8505327f2175cb9570f187b2288e0910077850dd Mon Sep 17 00:00:00 2001 From: Alec Pritchard Date: Tue, 2 Feb 2021 17:14:14 +0000 Subject: [PATCH] Always create flash messages, allow `enableFlashMessages` only to dictate display Fixed inconsistent handling of flash messages and the `enableFlashMessages` config setting (#391) --- src/User/Service/PasswordRecoveryService.php | 10 ++++------ src/User/Service/UserCreateService.php | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/User/Service/PasswordRecoveryService.php b/src/User/Service/PasswordRecoveryService.php index 9d6e2db..0e5b597 100644 --- a/src/User/Service/PasswordRecoveryService.php +++ b/src/User/Service/PasswordRecoveryService.php @@ -41,12 +41,10 @@ class PasswordRecoveryService implements ServiceInterface 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]) - ); - } + 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(); diff --git a/src/User/Service/UserCreateService.php b/src/User/Service/UserCreateService.php index 60ff7eb..26b9f59 100644 --- a/src/User/Service/UserCreateService.php +++ b/src/User/Service/UserCreateService.php @@ -75,8 +75,8 @@ class UserCreateService implements ServiceInterface 'Error sending welcome message to "{email}". Please try again later.', ['email' => $model->email] ); - // from web display a flash message (if enabled) - if ($this->getModule()->enableFlashMessages === true && is_a(Yii::$app, yii\web\Application::class)) { + // from web generate a flash message + if (is_a(Yii::$app, yii\web\Application::class)) { Yii::$app->session->setFlash( 'warning', $error_msg