Ejemplo n.º 1
0
 /**
  * Logs in a user using the provided username and password.
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate()) {
         $user = $this->getUser();
         $user->online = 1;
         $user->update(false);
         $Verified = \common\models\UserVerified::findOne(['user_id' => $user->id]);
         if (!$Verified || !$Verified->verificate_date) {
             Yii::$app->session->setFlash('verification', 'Для авторизации вам требуется подтвердить аккаунт. На указанный Вами email было выслано письмо содержащее ссылку для подтверждения аккаунта');
             return false;
         }
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $key
  * Verification account
  */
 public function actionVerificate($key)
 {
     $model = UserVerified::findOne(['key' => $key]);
     if ($model && !$model->verificate_date) {
         $model->verificate_date = time();
         if ($model->save()) {
             Yii::$app->session->setFlash('verification', 'Аккаунт активирован. Используйте свой логин и пароль для входа на сайт. ');
             $this->redirect('/site/login');
         }
     }
 }