/** * 登陆页面 */ function login() { if (isPost()) { $username = getRequest('username'); $password = getRequest('password'); $authCode = getRequest('authCode'); if (!$this->verifyPicCaptcha($authCode)) { $this->tpl->assign('error', '图片验证码不正确'); } else { $config = Swoole::$php->config['user']; $auth = new Swoole\Auth($config); $flag = $auth->login($username, $password); if ($flag) { $user = $auth->getUid(); $_SESSION["role"] = $user["role"]; $this->http->redirect(WEBROOT . "/home/index"); } else { $this->tpl->assign('error', '账户名或者密码错误'); } } } $this->tpl->display("page/login.html"); }