Skip to content

fix: custom oauth binding status never shown due to id type mismatch - #6573

Open
feitianbubu wants to merge 1 commit into
QuantumNous:mainfrom
feitianbubu:fix-custom-oauth-binding-display
Open

fix: custom oauth binding status never shown due to id type mismatch#6573
feitianbubu wants to merge 1 commit into
QuantumNous:mainfrom
feitianbubu:fix-custom-oauth-binding-display

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

个人资料页「账户绑定」里,自定义 OAuth 提供商永远显示「未绑定」,即使 user_oauth_bindings 表里有绑定记录。

原因:后端 /api/user/oauth/bindings 返回的 provider_id 是 JSON 数字(Go int),前端却用 b.provider_id === String(provider.id) 严格比较,数字和字符串永远不相等,所以 isBound 恒为 false。另外前端接口声明的 external_id 字段后端并不返回(实际字段叫 provider_user_id),绑定卡片上也一直显示不出第三方身份 ID。

改法:前端类型声明对齐后端响应(provider_id: numberprovider_user_id),按数字直接比较,卡片显示改用 provider_user_id

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • 无(自测发现,前端显示层类型比较错误,非设计取舍)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

修复前:
image

修复后:
image

Summary by CodeRabbit

  • Bug Fixes
    • Improved custom OAuth account binding compatibility by using numeric provider identifiers.
    • Updated bound account details to display the correct provider user identifier.
    • Improved unbinding behavior for custom OAuth providers.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Custom OAuth binding types now use numeric provider IDs and provider_user_id. Account binding lookup, display, and unbind calls use the updated identifiers.

Changes

Custom OAuth binding updates

Layer / File(s) Summary
Align custom OAuth binding contract and account display
web/src/features/profile/api.ts, web/src/features/profile/components/tabs/account-bindings-tab.tsx
CustomOAuthBinding uses numeric provider_id and optional provider_user_id. unbindCustomOAuth accepts a numeric provider ID. Account binding lookup compares provider IDs directly and displays provider_user_id.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: calcium-ion

Poem

A rabbit hops through OAuth bright,
With numbered keys aligned just right.
User IDs now show their name,
Bind and unbind share the same game.
Nibble, click, and ship tonight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the custom OAuth binding display bug caused by an ID type mismatch.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant