Commit 01cfd8803c1247ea50f48154f8a315ceb82957e2
1 parent
fe0fcefc
big commti
Showing
3 changed files
with
94 additions
and
0 deletions
Show diff stats
frontend/controllers/SiteController.php
| ... | ... | @@ -119,4 +119,31 @@ class SiteController extends Controller |
| 119 | 119 | 'model' => $model, |
| 120 | 120 | ]); |
| 121 | 121 | } |
| 122 | + | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * Resets password. | |
| 126 | + * | |
| 127 | + * @param string $token | |
| 128 | + * @return mixed | |
| 129 | + * @throws BadRequestHttpException | |
| 130 | + */ | |
| 131 | + public function actionResetPassword($token) | |
| 132 | + { | |
| 133 | + try { | |
| 134 | + $model = new ResetPasswordForm($token); | |
| 135 | + } catch (InvalidParamException $e) { | |
| 136 | + throw new BadRequestHttpException($e->getMessage()); | |
| 137 | + } | |
| 138 | + | |
| 139 | + if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { | |
| 140 | + Yii::$app->session->setFlash('success', 'New password was saved.'); | |
| 141 | + | |
| 142 | + return $this->goHome(); | |
| 143 | + } | |
| 144 | + | |
| 145 | + return $this->render('resetPassword', [ | |
| 146 | + 'model' => $model, | |
| 147 | + ]); | |
| 148 | + } | |
| 122 | 149 | } | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/* @var $this yii\web\View */ | |
| 4 | +/* @var $form yii\bootstrap\ActiveForm */ | |
| 5 | +/* @var $model \frontend\models\PasswordResetRequestForm */ | |
| 6 | + | |
| 7 | +use yii\helpers\Html; | |
| 8 | +use yii\bootstrap\ActiveForm; | |
| 9 | + | |
| 10 | +$this->title = 'Востановление пароля'; | |
| 11 | +$this->params['breadcrumbs'][] = $this->title; | |
| 12 | +?> | |
| 13 | +<div class="block-100"> | |
| 14 | + | |
| 15 | + <div class="container"> | |
| 16 | + <div class="site-request-password-reset"> | |
| 17 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 18 | + | |
| 19 | + <p>Заполните ваш Email. На него будет отправлена ссылка на восстановление пароля.</p> | |
| 20 | + | |
| 21 | + <div class="row"> | |
| 22 | + <div class="col-lg-5"> | |
| 23 | + <?php $form = ActiveForm::begin(['id' => 'request-password-reset-form']); ?> | |
| 24 | + | |
| 25 | + <?= $form->field($model, 'email')->textInput(['autofocus' => true]) ?> | |
| 26 | + | |
| 27 | + <div class="form-group"> | |
| 28 | + <?= Html::submitButton('Send', ['class' => 'btn btn-primary']) ?> | |
| 29 | + </div> | |
| 30 | + | |
| 31 | + <?php ActiveForm::end(); ?> | |
| 32 | + </div> | |
| 33 | + </div> | |
| 34 | + </div> | |
| 35 | + </div> | |
| 36 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/* @var $this yii\web\View */ | |
| 4 | +/* @var $form yii\bootstrap\ActiveForm */ | |
| 5 | +/* @var $model \frontend\models\ResetPasswordForm */ | |
| 6 | + | |
| 7 | +use yii\helpers\Html; | |
| 8 | +use yii\bootstrap\ActiveForm; | |
| 9 | + | |
| 10 | +$this->title = 'Reset password'; | |
| 11 | +$this->params['breadcrumbs'][] = $this->title; | |
| 12 | +?> | |
| 13 | +<div class="site-reset-password"> | |
| 14 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 15 | + | |
| 16 | + <p>Please choose your new password:</p> | |
| 17 | + | |
| 18 | + <div class="row"> | |
| 19 | + <div class="col-lg-5"> | |
| 20 | + <?php $form = ActiveForm::begin(['id' => 'reset-password-form']); ?> | |
| 21 | + | |
| 22 | + <?= $form->field($model, 'password')->passwordInput(['autofocus' => true]) ?> | |
| 23 | + | |
| 24 | + <div class="form-group"> | |
| 25 | + <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?> | |
| 26 | + </div> | |
| 27 | + | |
| 28 | + <?php ActiveForm::end(); ?> | |
| 29 | + </div> | |
| 30 | + </div> | |
| 31 | +</div> | ... | ... |