/**
  * Displays the login page.
  *
  * @return string|Response
  */
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         $this->goHome();
     }
     /** @var LoginForm $model */
     $model = Yii::createObject(LoginForm::className());
     $event = $this->getFormEvent($model);
     $this->performAjaxValidation($model);
     $this->trigger(self::EVENT_BEFORE_LOGIN, $event);
     if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) {
         $this->trigger(self::EVENT_AFTER_LOGIN, $event);
         return $this->goBack();
     }
     return $this->render('login', ['model' => $model, 'module' => $this->module]);
 }
Exemple #2
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     return $this->render('login', ['model' => \Yii::createObject(LoginForm::className())]);
 }