Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(profile): 修复未配置 Passkey 时 /profile 每次访问都弹「加载 Passkey 失败」 - #5024

#5024
Merged
Wei-Shaw merged 1 commit into
mainWei-Shaw/sub2api:mainfrom
fix/passkey-disabled-toastWei-Shaw/sub2api:fix/passkey-disabled-toastCopy head branch name to clipboard
Jul 29, 2026
Merged

fix(profile): 修复未配置 Passkey 时 /profile 每次访问都弹「加载 Passkey 失败」#5024
Wei-Shaw merged 1 commit into
mainWei-Shaw/sub2api:mainfrom
fix/passkey-disabled-toastWei-Shaw/sub2api:fix/passkey-disabled-toastCopy head branch name to clipboard

Conversation

@Wei-Shaw

Copy link
Copy Markdown
Owner

问题

未配置 WebAuthn(Passkey)的部署,每次访问 /profile 都会弹「加载 Passkey 失败」toast。

根因

ProfilePasskeyCard 的加载逻辑本来就设计为静默忽略 PASSKEY_DISABLED 错误,但比对了错误对象的错误字段:后端错误信封是 { code: 403, reason: "PASSKEY_DISABLED", message: ... } —— 字符串错误码在 reasoncode 是数字状态码。组件用 error.code !== 'PASSKEY_DISABLED' 判断,永远成立,静默逻辑完全失效。

此外组件在 enabled=false(公开设置 passkey_enabled 为 false)时也会发起 GET /user/passkeys 请求,注定 403,纯属无谓开销。

修复

  • 静默判断改为读 error.reason
  • enabled=false 时直接跳过请求;保留 reason 判断以覆盖设置变更竞态(前端认为已启用但后端刚关闭)

修复后:未配置 Passkey 时卡片只显示「功能未启用」提示,不发请求、不弹错误。

验证

  • ESLint 单文件检查通过
  • 静态核对了 api/client.ts 错误拦截器 reject 的结构({ status, code, reason, message })与后端 response.ErrorFrom 信封字段一一对应

The PASSKEY_DISABLED silence guard compared the string error code
against error.code, but the api client puts the numeric envelope code
there and the string code in error.reason, so the guard never matched
and every /profile visit on deployments without WebAuthn configured
showed a spurious "failed to load passkeys" toast.

Read error.reason instead, and skip the credentials request entirely
when the feature is disabled so the card no longer issues a request
that is guaranteed to fail with 403.
@Wei-Shaw
Wei-Shaw merged commit 6e1cbed into main Jul 29, 2026
20 of 22 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 29, 2026
@Wei-Shaw
Wei-Shaw deleted the fix/passkey-disabled-toast branch July 29, 2026 01:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.