Example #1
0
 public function actionRecover()
 {
     $model = new Recover();
     if ($model->load(Yii::$app->request->getBodyParams(), '') && $model->validate()) {
         if ($model->resetPassword()) {
             return ['success' => true];
         }
     } else {
         return $model;
     }
 }
Example #2
0
 public function actionRecover()
 {
     $isRecovered = false;
     $sendModel = new SendEmail();
     $recoverModel = new Recover();
     if ($sendModel->load(Yii::$app->request->post())) {
         if ($sendModel->validate()) {
             if ($sendModel->sendEmail()) {
                 Yii::$app->session->setFlash('success', 'Секретный код отправлен на указанный email. ');
             }
         }
     }
     if ($recoverModel->load(Yii::$app->request->post())) {
         if ($recoverModel->validate()) {
             if ($recoverModel->recover()) {
                 $isRecovered = true;
                 Yii::$app->session->setFlash('success', 'Ваш пароль успешно изменён. ');
                 return $this->goHome();
             }
         }
     }
     return $this->render('recover', ['sendModel' => $sendModel, 'recoverModel' => $recoverModel, 'isRecovered' => $isRecovered]);
 }