예제 #1
0
 /**
  * Авторизация пользователя
  * @return string|\yii\web\Response
  */
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
예제 #2
0
 /**
  * Login user.
  */
 public function actionIndex()
 {
     if (!Yii::$app->user->isGuest) {
         $this->goHome();
     }
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             if ($model->login()) {
                 return $this->goHome();
             }
         } elseif (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
     }
     return $this->render('index', ['model' => $model]);
 }
예제 #3
0
 /**
  * Авторизируем пользователя
  */
 public function actionLogin()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $this->layout = '@backend/modules/user/views/layouts/main';
     $model = new LoginForm();
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }