/** * User login */ public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $userDriver = isset(\Yii::$app->params['user_driver']) == true && empty(\Yii::$app->params['user_driver']) == false ? strtolower(\Yii::$app->params['user_driver']) : 'local'; if ($userDriver == 'ldap') { if (isset(\Yii::$app->params['ldap']) == false) { throw new \Exception(yii::t('walle', 'the login dirver configs does not defined', array('loginType' => \Yii::$app->params['user_driver']))); } if (is_array(\Yii::$app->params['ldap']) == false) { throw new \Exception(yii::t('walle', 'the login dirver configs parse error', array('loginType' => \Yii::$app->params['user_driver']))); } $model = new LdapLoginForm(\Yii::$app->params['ldap']); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('login', ['isLdapLigin' => true, 'model' => $model]); } } elseif ($userDriver == 'local') { $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('login', ['isLdapLigin' => false, 'model' => $model]); } } else { throw new \Exception(yii::t('walle', 'login type could not support', array('loginType' => \Yii::$app->params['user_driver']))); } }
public function actionValidateLoginForm() { $logFrm = new LoginForm(); if (Yii::$app->request->isAjax && $logFrm->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($logFrm); } }
public function actionLogin() { if (!Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } return $this->render('login', ['model' => $model]); }
public function actionLogin($showCaptcha = false) { if ($showCaptcha) { $logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN_CAPTCHA]); } else { $logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN]); } if ($logFrm->load(Yii::$app->request->post()) && $logFrm->validate()) { $companyID = $logFrm->login(); if ($companyID) { return $this->redirect(Url::to('/private-room/?id=' . $companyID)); } } return $this->goHome(); }
public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); // ajax validation if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = 'json'; return \yii\widgets\ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('login', ['model' => $model]); } }