public function actionLogin() { if (!\Yii::$app->user->isGuest) { $this->goHome(); } $model = \Yii::createObject(\app\models\LoginForm::className()); $this->performAjaxValidation($model); if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) { Yii::$app->session->setFlash('success', Yii::t('app', 'Welcome') . " " . Yii::$app->user->identity->username); // $this->goHome(); return $this->goBack(); } return $this->render('login', ['model' => $model, 'module' => $this->module]); }
/** * Displays the login page. * * @return string|\yii\web\Response */ public function actionLogin() { $model = \Yii::createObject(LoginForm::className()); // $this->layout = '//guest'; $this->performAjaxValidation($model); if ($model->load(\Yii::$app->getRequest()->post()) && $model->login()) { $model->login(); $this->redirect(['/account/alerts']); } else { if (!\Yii::$app->request->isAjax) { $this->redirect(['/site/index', 'login' => true]); } } return $this->renderAjax('//user/security/login', ['model' => $model, 'module' => $this->module]); }