From 5d22d2b5f561cc0b9de31c7435cd671ce16957a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Thu, 20 Aug 2026 11:40:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(login):=20pcLogin=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E7=9C=9F=E6=9C=BA=E4=BF=AE=E6=AD=A3(phone/loginType/companyCod?= =?UTF-8?q?e)+secureKey=E6=8D=A2usercenter=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 浏览器实登抓包确认:POST /usercenter/login/getSecureKey(非newuc GET) + body {phone,password(RSA-hex),loginType:'yunkecn',companyCode} 实测从500系统错误推进到10300密码错误=协议通,剩加密细节/密码核对(余5次重试暂停试错防锁号) Co-Authored-By: Claude --- yunke-server/app/session/login.py | 7 ++++++- yunke-server/app/session/yunke_client.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/yunke-server/app/session/login.py b/yunke-server/app/session/login.py index 3bada83..c0cf218 100644 --- a/yunke-server/app/session/login.py +++ b/yunke-server/app/session/login.py @@ -144,6 +144,7 @@ async def pc_login( username: str, password: str, secure_key: dict[str, Any], + company_code: str = "", ) -> LoginResult: """Call ``POST {base}/usercenter/login/pcLogin`` and parse a LoginResult. @@ -164,9 +165,13 @@ async def pc_login( httpx client's cookie jar — ``pcLogin``'s ``Set-Cookie`` lands there automatically. """ + # 真机抓包(2026-08-20 浏览器实登)确认的字段:phone/loginType/companyCode + # (旧 account 变体一直被拒"缺少登录参数") body = { - "account": username, + "phone": username, "password": encrypt_password(password, secure_key), + "loginType": "yunkecn", + "companyCode": company_code, } resp = await client.post("/usercenter/login/pcLogin", json=body) resp.raise_for_status() diff --git a/yunke-server/app/session/yunke_client.py b/yunke-server/app/session/yunke_client.py index b393de2..3831536 100644 --- a/yunke-server/app/session/yunke_client.py +++ b/yunke-server/app/session/yunke_client.py @@ -211,8 +211,14 @@ class YunkeClient: " client was constructed from an existing session." ) secure_key = await get_secure_key(self._client) + from app.config import get_settings + result = await pc_login( - self._client, self.username, self.password, secure_key + self._client, + self.username, + self.password, + secure_key, + company_code=get_settings().yk_company or "", ) self.login_result = result return result