Skip to content

fix(dumate): 扫码登录后补齐 bce-user-info,修复领取报 csrftoken 缺失 - #67

Merged
techysy merged 2 commits into
techysy:mainfrom
lu8010252:fix/dumate-bce-user-info
Nov 15, 2026
Merged

techysy merged 2 commits into
techysy:mainfrom
lu8010252:fix/dumate-bce-user-info

Conversation

@lu8010252

Copy link
Copy Markdown
Contributor

现象

扫码登录成功后,账号能正常显示余额,但每日领取失败:

[DuMate] 领取失败:Cookie 缺少 bce-user-info(无法生成 csrftoken)

根因

扫码链路走完 console.bce.baidu.com/dumate/channel 后,会话里只有 BDUSS / bce-sessionid,
控制台首页并不下发 bce-user-info。而领取接口需要 csrftoken,其值等于 bce-user-info 的原文,
extractDumateCsrfToken() 取不到就返回空,请求被直接拦下。

修复

新增 healDumateCookies():缺少 bce-user-info 时请求
GET /api/dumate/app/token/get,从响应 Set-Cookie 里取 bce-login-accountid
作为 bce-user-info 的值(该接口还会一并返回 bce-login-display-name、bce-device-token,一并合并进会话)。

两处调用:

  • dumateQr.js:扫码登录收集完 Cookie 后补齐,保证入库账号是完整的;
  • dumateClient.js:领取前兜底一次,存量账号无需重新登录。

顺带修了 checkin.js 的一个显示问题:当 provider 未返回积分数量时,日志会打印 领取成功 +undefined 积分,
现在改为打印「领取成功(接口未返回积分数量)」;有数量时行为不变。

实测

补齐后调用领取接口:

{"status":"checked-in","message":"已领取今日登录赠送积分"}

对照实验:把 bce-user-info 写成 timestamp|accountId,接口返回「登录凭证已过期」;
写成纯 accountId 才成功。说明服务端按 cookie 原文与 csrftoken 双提交校验,值必须是账户 ID 本身。

测试说明

  • node --check 通过;
  • 上游 npm test 在提交机器上无法运行(Node 启动即 Zone Allocation failed 的环境问题),未做单元测试;
  • 已在 Docker 容器内用真实账号验证上述领取结果。

现象:扫码登录成功后,账号能查到余额,但每日领取失败并提示
「Cookie 缺少 bce-user-info(无法生成 csrftoken)」。

原因:控制台首页(/dumate/channel 等)并不下发 bce-user-info,
会话里只有 BDUSS / bce-sessionid 时 extractDumateCsrfToken 返回空。

修复:新增 healDumateCookies(),缺该 cookie 时请求
/api/dumate/app/token/get,从 Set-Cookie 的 bce-login-accountid
取账户 ID 作为 bce-user-info 的值(实测该值就是账户 ID,服务端按
cookie 原文与 csrftoken 双提交校验)。扫码链路入库前补齐,
领取时也兜底一次,避免存量账号需要重新登录。

实测:补齐后领取接口返回 checked-in「已领取今日登录赠送积分」;
若把值写成 timestamp|accountId 则返回「登录凭证已过期」,
确认必须为纯账户 ID。
@techysy
techysy merged commit 4bf0d23 into techysy:main Nov 15, 2026
techysy added a commit that referenced this pull request Nov 15, 2026
techysy added a commit that referenced this pull request Nov 15, 2026
techysy added a commit that referenced this pull request Nov 15, 2026
PR #67 的 heal 是内存态:verify/领取前现补一轮 token/get,heal 出的
bce-login-accountid / display-name / device-token 不落库——每次领取都
重补一遍,且补出的新 Cookie 从未持久化。

- refreshContext 补 persistCookieJar(cookieHeader):完整罐回写账号
  token 与 cookieSiteSession.cookie(与 onRefresh 同构,log 同步)
- checkinDumate 接 persistCookieJar:heal 成功后回写(回写失败不阻断
  领取);providers dumate 传 ctx
- 测试补两例:heal 后回写断言 + 无钩子时兼容(不强加依赖)

Co-Authored-By: Claude Code <noreply@anthropic.com>
techysy added a commit that referenced this pull request Nov 16, 2026
- 版本号对齐 v1.8.0(root/desktop package.json + fnos manifest)
- CHANGELOG 四语封版 2026-11-16:主题行改最终架构口径(Meoo 以网页会话接入,OAuth 独立线试运行一轮后回退);PR #67 条目黏连剥离并补 heal 落库(persistCookieJar);meoo 回退条目补全撤除细节;渠道推送收口条目归位;测试数校准 466/466

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants