Exemplo n.º 1
0
 /**
  * Вход на сайт
  * @return string|Response
  */
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $loginForm = new LoginForm();
     $passwordResetRequestForm = new PasswordResetRequestForm();
     if ($loginForm->load(Yii::$app->request->post())) {
         //sql
         if ($loginForm->login()) {
             return $this->goHome();
         } else {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return $loginForm->getFormattedError();
         }
     }
     Yii::$app->assetManager->bundles['AppAsset'] = true;
     return $this->renderAjax('login', ['loginForm' => $loginForm, 'passwordResetRequestForm' => $passwordResetRequestForm]);
 }