Esempio n. 1
0
 /**
  * Logs in a user.
  *
  * @return 登陆
  */
 public function actionLogin()
 {
     $model = new Lguser();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             $User = new User();
             if ($userinfo = $User->Checklgin($this->request->post('Lguser'))) {
                 if ($userinfo['code'] == 1) {
                     $this->actionTotrans('成功', '个人主页', 'student/index', $userinfo);
                 } else {
                     $this->actionTotrans('错误', '返回', 'site/login', $userinfo);
                 }
             }
             //return $this->goBack();
         } else {
             $errors = $model->errors;
             if (count($errors) > 1) {
                 $user = array('code' => 5, 'data' => '非法注册,请通过正确途径注册');
                 $this->actionTotrans('错诶', '登陆页', 'site/login', $user);
             } else {
                 $val = array_values($errors);
                 $user = array('code' => 6, 'data' => $val[0][0]);
                 $this->actionTotrans('错诶', '登陆页', 'site/login', $user);
             }
         }
     }
     return $this->render('login', ['model' => $model]);
 }