双份cookie存储:raw_cookie 保存App原始凭据,与网页运行ck分离
网页运行ck(cookie列)含本地随机生成的网页设备字段,若被风控标记 无法还原纯净登录凭据;新增 raw_cookie 保存16字段App原始态,供 设备态重建/审计/复核登录有效性。 - HuyaAccount 加 raw_cookie 列(alembic 0034,MySQL TEXT nullable) - HuyaLoginResult 加 raw_cookie 字段;App登录链补齐前快照原始凭据 - upsert_huya_cookie 支持双写;app-password-login 路由透传 raw_cookie - 存量行 raw_cookie 为 NULL(老账号无快照),新登录自动填充
This commit is contained in:
@@ -303,9 +303,18 @@ def save_huya_login_cookie_to_account(
|
||||
|
||||
|
||||
def upsert_huya_cookie(
|
||||
db: Session, cookie: str, tag: str = "", username_hint: str = ""
|
||||
db: Session,
|
||||
cookie: str,
|
||||
tag: str = "",
|
||||
username_hint: str = "",
|
||||
raw_cookie: str = "",
|
||||
) -> HuyaAccount:
|
||||
"""保存单条登录得到的虎牙 Cookie。"""
|
||||
"""保存单条登录得到的虎牙 Cookie。
|
||||
|
||||
Args:
|
||||
cookie: 网页运行 Cookie(可能含本地生成的网页设备字段)。
|
||||
raw_cookie: App 原始登录凭据(不含网页设备字段),单独落库供重建/审计。
|
||||
"""
|
||||
line = f"{username_hint}----{cookie}" if username_hint else cookie
|
||||
parsed = parse_huya_cookie_line(line)
|
||||
if not parsed:
|
||||
@@ -313,6 +322,8 @@ def upsert_huya_cookie(
|
||||
account = _upsert_huya_account(
|
||||
db, parsed, tag=(tag or "").strip(), status="login_success"
|
||||
)
|
||||
if raw_cookie:
|
||||
account.raw_cookie = normalize_huya_cookie(raw_cookie)
|
||||
db.commit()
|
||||
db.refresh(account)
|
||||
return account
|
||||
|
||||
Reference in New Issue
Block a user