修复无法登陆的问题

This commit is contained in:
jingrow 2026-03-10 23:39:58 +08:00
parent 0cce311cae
commit 882278108b
3 changed files with 37 additions and 3 deletions

View File

@ -271,7 +271,15 @@ async def saas_login(request: Request):
raise HTTPException(status_code=401, detail=result.get("message", "登录失败"))
session_cookie = result.get("session_cookie")
return create_response_with_cookie({"message": result.get("message", "Logged In")}, session_cookie)
response = JSONResponse(content={"message": result.get("message", "Logged In")})
if session_cookie:
response.set_cookie(key="sid", value=session_cookie, **COOKIE_CONFIG)
response.set_cookie(key="user_id", value=username, path="/", samesite="lax")
response.set_cookie(key="full_name", value=username, path="/", samesite="lax")
response.set_cookie(key="system_user", value="yes", path="/", samesite="lax")
return response
@router.api_route("/api/action/logout", methods=["GET", "POST"])

View File

@ -0,0 +1,27 @@
# Copyright (c) 2025, JINGROW and contributors
# For license information, please see license.txt
"""
实时通信相关白名单函数 - 转发到 SaaS
"""
import jingrow
import requests
from jingrow.config import Config
from jingrow.utils.auth import get_request_session_cookie
@jingrow.whitelist(allow_guest=True)
def get_user_info():
"""获取用户信息 - 转发到 SaaS 端"""
url = f"{Config.jingrow_server_url}/api/action/jingrow.realtime.get_user_info"
headers = {"Accept": "application/json"}
session_cookie = get_request_session_cookie()
if session_cookie:
headers["Cookie"] = f"sid={session_cookie}"
resp = requests.get(url, headers=headers, timeout=30)
if resp.status_code == 200:
return resp.json().get("message", {})
return {}

View File

@ -108,10 +108,9 @@ async def _process_whitelist_call(request: Request, full_module_path: str):
except Exception:
request_data = {}
# 调用函数(只有通过白名单验证的函数才能执行到这里)
result = func(**request_data)
return JSONResponse(content={"success": True, "data": result})
return JSONResponse(content={"message": result})
except HTTPException:
raise