/** * Page to redirect after login * @return string|Response * @throws \yii\base\InvalidConfigException */ public function actionPassword() { if (!\Yii::$app->user->isGuest) { $this->goHome(); } /** @var LoginForm $model */ $model = \Yii::createObject(LoginForm::className(), ['scenario' => 'login']); //check if user was found if ($model->load(Yii::$app->getRequest()->post()) && $model->validate() && $model->getIsIdentified()) { //Is it no card present ? So validate password. if (!$model->getIsLoginByCard()) { $model->scenario = 'password'; //validate password! $this->performAjaxValidation($model); } //set attributes changed scenario & login if ($model->load(Yii::$app->getRequest()->post()) && $model->login()) { return $this->goBack(); } $model->clearErrors('Password'); return $this->render('password', ['model' => $model, 'module' => $this->module]); } else { //validate login $this->performAjaxValidation($model); return $this->goBack(Yii::$app->homeUrl); } }