writeSuccess('登录成功', [ 'base64' => $captchaData['data']['base64'] ?? '', 'text' => $captchaData['data']['text'] ?? '', ]); } public function index() { $username = $this->request->post('username', ''); $password = $this->request->post('password', ''); $remember = $this->request->post('remember', false); $code = $this->request->post('code', ''); $loginService = new LoginService(); try { $result = $loginService->login($this->request, $this->request->getClient(), $username, $password, $code, $remember); // 绑定Auth $this->request->setAuth(new HttpAuth($result['user']['userId'], UserTypeEnum::USER)); security_log_record([SysUser::class, "userLogin"], "{$username}登录了系统", ''); } catch (ValidateException $e) { return $this->writeError($e->getError()); } return $this->writeSuccess('登录成功', ['user' => $result['user'], 'access_token' => $result['access_token']]); } }