C7/C8: employees.last_login_ip 列补全(ALTER TABLE 迁移)+ redis decode 兼容修复 7 处(wecom_service×2/employee_directory×3/auth_wecom_sso×2,统一 isinstance 保护模式)
This commit is contained in:
@@ -224,12 +224,14 @@ async def sso_callback(
|
||||
# 解析 state 数据(添加异常处理)
|
||||
import ast
|
||||
import json
|
||||
# v4.0 C8 修复:decode_responses=True 时 state_raw 已是 str
|
||||
state_raw = state_raw if isinstance(state_raw, str) else state_raw.decode("utf-8")
|
||||
try:
|
||||
state_data = json.loads(state_raw.decode("utf-8"))
|
||||
state_data = json.loads(state_raw)
|
||||
except (json.JSONDecodeError, AttributeError) as e:
|
||||
# 兼容旧格式(使用 ast.literal_eval)
|
||||
try:
|
||||
state_data = ast.literal_eval(state_raw.decode("utf-8"))
|
||||
state_data = ast.literal_eval(state_raw)
|
||||
except (ValueError, SyntaxError) as e2:
|
||||
logger.error(f"SSO callback state 解析失败: {e2}")
|
||||
return RedirectResponse(url=_get_error_redirect_url("state_invalid", "授权信息无效,请重新进入", next_path), status_code=302)
|
||||
@@ -368,7 +370,9 @@ async def sso_verify(
|
||||
# 一次性 token(防止泄漏后被滥用)
|
||||
await redis_client.delete(f"wecom_sso:token:{sso_token}")
|
||||
|
||||
payload = json.loads(token_raw.decode("utf-8"))
|
||||
# v4.0 C8 修复:兼容 str/bytes
|
||||
token_raw = token_raw if isinstance(token_raw, str) else token_raw.decode("utf-8")
|
||||
payload = json.loads(token_raw)
|
||||
return success_response(data=payload)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user