Always create flash messages, allow enableFlashMessages only to dictate display

Fixed inconsistent handling of flash messages and the `enableFlashMessages` config setting (#391)
This commit is contained in:
Alec Pritchard
2021-02-02 17:14:14 +00:00
parent 12ce0e67f2
commit 8505327f21
2 changed files with 6 additions and 8 deletions

View File

@ -41,12 +41,10 @@ class PasswordRecoveryService implements ServiceInterface
public function run() public function run()
{ {
try { try {
if ($this->getModule()->enableFlashMessages == true) { Yii::$app->session->setFlash(
Yii::$app->session->setFlash( 'info',
'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::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 */ /** @var User $user */
$user = $this->query->whereEmail($this->email)->one(); $user = $this->query->whereEmail($this->email)->one();

View File

@ -75,8 +75,8 @@ class UserCreateService implements ServiceInterface
'Error sending welcome message to "{email}". Please try again later.', 'Error sending welcome message to "{email}". Please try again later.',
['email' => $model->email] ['email' => $model->email]
); );
// from web display a flash message (if enabled) // from web generate a flash message
if ($this->getModule()->enableFlashMessages === true && is_a(Yii::$app, yii\web\Application::class)) { if (is_a(Yii::$app, yii\web\Application::class)) {
Yii::$app->session->setFlash( Yii::$app->session->setFlash(
'warning', 'warning',
$error_msg $error_msg