Skip to content

fix(139): surface SMS verification during refresh fallback - #190

Merged
PIKACHUIM merged 1 commit into
mainfrom
fix/139-sms-refresh-fallback
Nov 9, 2026
Merged

PIKACHUIM merged 1 commit into
mainfrom
fix/139-sms-refresh-fallback

Conversation

@PIKACHUIM

Copy link
Copy Markdown
Member

后续 PR 正文

fix(139): surface SMS verification during refresh fallback

基线:origin/main = 38cfdc4(#164 的 squash merge)
分支:fix/139-sms-refresh-fallback
提交:67e0601 fix(139): surface SMS verification during refresh fallback

Summary / 摘要

#164 的 squash merge 漏掉了最后一个提交 ff8c863。本 PR 补上这一行:刷新失败触发密码重登录、且 139 邮箱要求短信验证时,不再吞掉 Yun139SmsRequiredError,而是先保存更新后的 MailCookies,再把“请填写 sms_code”的错误抛给用户。

Motivation / 背景

  • 原 PR 合并到 main 时只到 9bfd4fe,缺少 ff8c863。
  • 当前 main 的 tryReLogin() 捕获短信风控异常后只写 debug 日志并 return false,外层最终抛出 PC/旧接口刷新错误,用户看不到需要填写验证码的提示。
  • 行为与 Go 的 loginAfterAuthorizationFailure 不一致:Go 会把登录错误(含短信提示)返回给用户。

Changes / 改动内容

src/backend/drivers/139/util.ts:

  • tryReLogin() 捕获 Yun139SmsRequiredError 时:
    1. 更新 addition.mail_cookies;
    2. 通过 onLoginStateChange 持久化;
    3. throw e,让调用方收到短信验证提示。
  • 其他登录失败仍保持原有降级:debug 日志 + return false。
if (e instanceof Yun139SmsRequiredError) {
  this.addition.mail_cookies = e.mailCookies
  await this.onLoginStateChange?.({
    authorization: "",
    account: this.account,
    userDomainId: (this.addition.user_domain_id || "").trim(),
    mailCookies: e.mailCookies,
    smsCode: (this.addition.sms_code || "").trim(),
  })
  throw e
}

Testing / 验证

npx tsx --test src/backend/drivers/139/*.test.ts
# 25 passed / 0 failed

npx tsc -p tsconfig.json --noEmit
# 无报错

Compatibility / 兼容性

  • 单行行为修复,无接口、配置、数据库变更。
  • 不影响没有用户名/密码的配置:仍走原有刷新或跳过逻辑。
  • 不改变手动 user_domain_id 与 Authorization 的优先级。
  • 不改变已有刷新成功路径。
  • 不影响没有触发短信风控的密码重登录。

Checklist

When a refresh failure triggers password login and 139 Mail asks for an
SMS code, propagate Yun139SmsRequiredError instead of swallowing it and
reporting only the original refresh error. The refreshed mail_cookies are
still persisted first, so the next save with sms_code can continue.

Tests: 139 driver 25/25, tsc clean.
@PIKACHUIM PIKACHUIM linked an issue Nov 9, 2026 that may be closed by this pull request
4 tasks done
@PIKACHUIM
PIKACHUIM merged commit 6e11cfb into main Nov 9, 2026
3 checks passed
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.

[BUG] 139云盘configure user_domain_id to use the PC refreshToken API

1 participant