public function actionLogin() { $request = Yii::$app->request; if (!$request->isAjax || !$request->isPost) { throw new \yii\web\NotFoundHttpException(404); } $post = $request->post("data"); // 前台提交的数据缺一不可 if (!$post['account'] || !$post['passwd'] || !$post['code']) { throw new \yii\web\NotFoundHttpException(404); } // 检查验证码 $session = Yii::$app->session; if (@$session['login_code'] != strtolower($post['code'])) { return json_encode($this->makeRes('fail', "验证码输入错误!")); } // 用户名密码检查 $account = trim($post['account']); $passwd = md5($post['passwd']); $checkRes = Rz_user::User_login($account, $passwd); if (!$checkRes) { return json_encode($this->makeRes('fail', "用户名或密码错误!")); } // 账户是否被冻结? if ($checkRes['status']) { return json_encode($this->makeRes('fail', "账户被冻结,请联系客服:" . $this->_GOLBELS['cfg_kftel'])); } // 登陆成功 存储信息 删除登陆session 发送跳转请求 $session->remove('login_code'); $session->set('userid', $checkRes['id']); $session->set('account', $checkRes['account']); $session->set('username', $checkRes['nickname']); $session->set('lgtime', time()); return json_encode($this->makeRes('success', "/")); }