public function login() { $username = trim($_POST['username']); $password = trim($_POST['password']); $verify_code = trim($_POST['verifycode']); if ($verify_code != $_SESSION['Checknum']) { $this->exit_with_error(1, '验证码错误', 400); } if ($username == '' || $password == '') { $this->exit_with_error(2, '用户名或密码不能为空', 422); } $service = new Auth(); $pass = $service->validate($username, $password); if (!$pass) { $this->exit_with_error(3, '用户名或密码错误', 400); } // 只向技术和商务开放 if (!$service->has_permission()) { $this->exit_with_error(4, '暂时只向商务开放', 400); } $me = $this->get_user_info(); $result = array('code' => 0, 'msg' => '登录成功', 'me' => $me); $this->output($result); }