From 2ee61228391c8909ef0c2a688673df4f698ff93a Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Sat, 1 Apr 2017 12:01:30 +0200 Subject: [PATCH] also refactor actionReset() and RegistrationController actionRegister() to use separate views. This also makes overwriting the views with custom messages much easier. --- controllers/RecoveryController.php | 22 ++++++++-------------- controllers/RegistrationController.php | 5 +---- views/recovery/password_change_success.php | 1 + views/recovery/recovery_token_invalid.php | 6 ++++++ views/registration/register_success.php | 1 + 5 files changed, 17 insertions(+), 18 deletions(-) create mode 100644 views/recovery/password_change_success.php create mode 100644 views/recovery/recovery_token_invalid.php create mode 100644 views/registration/register_success.php diff --git a/controllers/RecoveryController.php b/controllers/RecoveryController.php index c5c98db6d..b3f2abc77 100644 --- a/controllers/RecoveryController.php +++ b/controllers/RecoveryController.php @@ -120,7 +120,7 @@ public function actionRequest() if ($model->load(\Yii::$app->request->post()) && $model->sendRecoveryMessage()) { $this->trigger(self::EVENT_AFTER_REQUEST, $event); - return $this->render('/recovery/request_sent'); + return $this->render('request_sent'); } return $this->render('request', [ @@ -150,15 +150,12 @@ public function actionReset($id, $code) $this->trigger(self::EVENT_BEFORE_TOKEN_VALIDATE, $event); if ($token === null || $token->isExpired || $token->user === null) { - $this->trigger(self::EVENT_AFTER_TOKEN_VALIDATE, $event); - \Yii::$app->session->setFlash( - 'danger', - \Yii::t('user', 'Recovery link is invalid or expired. Please try requesting a new one.') - ); - return $this->render('/message', [ - 'title' => \Yii::t('user', 'Invalid or expired link'), - 'module' => $this->module, - ]); + $this->trigger(self::EVENT_AFTER_TOKEN_VALIDATE, $event); + \Yii::$app->session->setFlash( + 'danger', + \Yii::t('user', 'Recovery link is invalid or expired. Please try requesting a new one.') + ); + return $this->render('link_invalid'); } /** @var RecoveryForm $model */ @@ -173,10 +170,7 @@ public function actionReset($id, $code) if ($model->load(\Yii::$app->getRequest()->post()) && $model->resetPassword($token)) { $this->trigger(self::EVENT_AFTER_RESET, $event); - return $this->render('/message', [ - 'title' => \Yii::t('user', 'Password has been changed'), - 'module' => $this->module, - ]); + return $this->render('password_change_success'); } return $this->render('reset', [ diff --git a/controllers/RegistrationController.php b/controllers/RegistrationController.php index 898c635b5..f70b690dc 100644 --- a/controllers/RegistrationController.php +++ b/controllers/RegistrationController.php @@ -136,10 +136,7 @@ public function actionRegister() if ($model->load(\Yii::$app->request->post()) && $model->register()) { $this->trigger(self::EVENT_AFTER_REGISTER, $event); - return $this->render('/message', [ - 'title' => \Yii::t('user', 'Your account has been created'), - 'module' => $this->module, - ]); + return $this->render('register_success'); } return $this->render('register', [ diff --git a/views/recovery/password_change_success.php b/views/recovery/password_change_success.php new file mode 100644 index 000000000..6737cfe84 --- /dev/null +++ b/views/recovery/password_change_success.php @@ -0,0 +1 @@ + diff --git a/views/recovery/recovery_token_invalid.php b/views/recovery/recovery_token_invalid.php new file mode 100644 index 000000000..2f9e3c197 --- /dev/null +++ b/views/recovery/recovery_token_invalid.php @@ -0,0 +1,6 @@ + + + + +

'btn btn-primary']); ?>

+ diff --git a/views/registration/register_success.php b/views/registration/register_success.php new file mode 100644 index 000000000..29d670793 --- /dev/null +++ b/views/registration/register_success.php @@ -0,0 +1 @@ +.