Skip to content

Commit

Permalink
Merge branch 'refactor-recovery-controller' of https://github.com/thy…
Browse files Browse the repository at this point in the history
…seus/yii2-user into refactor-recovery-controller
  • Loading branch information
thyseus committed Apr 11, 2017
2 parents 40df53d + 2ee6122 commit f07cab6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
22 changes: 8 additions & 14 deletions controllers/RecoveryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down Expand Up @@ -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 */
Expand All @@ -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', [
Expand Down
5 changes: 1 addition & 4 deletions controllers/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
1 change: 1 addition & 0 deletions views/recovery/password_change_success.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?= \Yii::t('user', 'Password has been changed'); ?>
6 changes: 6 additions & 0 deletions views/recovery/recovery_token_invalid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php use yii\helpers\Html; ?>

<?= \Yii::t('user', 'Invalid or expired link'); ?>

<p> <?= Html::a(Yii::t('user', 'Back to Login'), ['//user/security/login'], ['class' => 'btn btn-primary']); ?> </p>

1 change: 1 addition & 0 deletions views/registration/register_success.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php echo \Yii::t('user', 'Your account has been created'); ?>.

0 comments on commit f07cab6

Please sign in to comment.