model; $model->setScenario('signIn'); if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) { return ($this->redirectUrl) ? $this->redirect($this->redirectUrl) : $this->goHome();; } elseif (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ['error' => Yii::t('app', 'Incorrect email or password')]; } return $this->render($this->view, ['model' => $model]); } }