Esempio n. 1
0
 /**
  * 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'])));
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 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]);
 }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
 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]);
     }
 }