Beispiel #1
0
 public function actionFinishReg($id)
 {
     /* @var $modelUser \common\models\User */
     /* @var $model \frontend\models\RegForm */
     $modelUser = User::findOne($id);
     if ($modelUser->email == '') {
         $model = new RegForm(['scenario' => 'phoneAndEmailFinish']);
     } elseif ($modelUser->email != '') {
         $model = new RegForm(['scenario' => 'phoneFinish']);
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($modelUser = $model->finishReg($id)) {
             if ($modelUser->status === User::STATUS_ACTIVE) {
                 if (Yii::$app->getUser()->login($modelUser)) {
                     return $this->goHome();
                 }
             } else {
                 if ($model->sendActivationEmail($modelUser)) {
                     Yii::$app->session->setFlash('success', 'Письмо с активацией отправлено на емайл <strong>' . Html::encode($modelUser->email) . '</strong> (проверьте папку спам).');
                     return $this->redirect(Url::to(['/main/login']));
                 } else {
                     Yii::$app->session->setFlash('error', 'Ошибка. Письмо не отправлено.');
                     Yii::error('Ошибка отправки письма.');
                 }
                 return $this->refresh();
             }
         } else {
             Yii::$app->session->setFlash('error', 'Возникла ошибка при регистрации.');
             Yii::error('Ошибка при регистрации');
             return $this->refresh();
         }
     }
     return $this->render('reg', ['modelUser' => $modelUser, 'model' => $model]);
 }
Beispiel #2
0
 public function actionFinishReg($id)
 {
     /* @var $modelUser \common\models\User */
     /* @var $model \frontend\models\RegForm */
     $modelUser = User::findOne($id);
     if ($modelUser->email == '') {
         $model = new RegForm(['scenario' => 'phoneAndEmailFinish']);
     } elseif ($modelUser->email != '') {
         $model = new RegForm(['scenario' => 'phoneFinish']);
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($modelUser = $model->finishReg($id)) {
             if ($modelUser->status === User::STATUS_ACTIVE) {
                 if (Yii::$app->getUser()->login($modelUser)) {
                     return $this->goHome();
                 }
             } else {
                 if ($model->sendActivationEmail($modelUser)) {
                     Yii::$app->session->setFlash('success', Yii::t('app', 'Letter to activate your account was sent to the email <strong> {email} </strong> (check spam folder).', ['email' => $modelUser->email]));
                     return $this->redirect(Url::to(['/ad/view/all']));
                 } else {
                     Yii::$app->session->setFlash('error', Yii::t('app', 'Error. The letter was not sent.'));
                     Yii::error(Yii::t('app', 'Error. The letter was not sent.'));
                 }
                 return $this->refresh();
             }
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'There was an error during the registration process.'));
             Yii::error(Yii::t('app', 'There was an error during the registration process.'));
             return $this->refresh();
         }
     }
     return $this->render('reg', ['modelUser' => $modelUser, 'model' => $model]);
 }