Skip to content

feat(auth): 前端接入 Discord 登录 + 设置页登录方式管理#382

Merged
longsizhuo merged 1 commit into
mainfrom
feat/discord-login-frontend
Jul 19, 2026
Merged

feat(auth): 前端接入 Discord 登录 + 设置页登录方式管理#382
longsizhuo merged 1 commit into
mainfrom
feat/discord-login-frontend

Conversation

@longsizhuo

Copy link
Copy Markdown
Member

配合后端 Discord provider(involutionhell-backend#48,已合 main)。这是"Discord 登录"的前端一半。

改动

  • next.config.mjs(关键阻断修复):OAuth 回调 rewrite 从硬编码 /api/auth/callback/github 泛化为 /api/auth/callback/:provider。原来 Discord 回调 /api/auth/callback/discord 漏代理 → 落到 Vercel 前端 404,登录整个跑不通。
  • 登录页 Discord 按钮SignInButton 参数化 provider(header 处无 props 调用默认 github,不变);登录页并列 GitHub / Discord 两个按钮。
  • 设置页「登录方式」区LinkedAccounts.tsx):列出已绑定身份 + 解绑,用后端 M2a 的 GET/DELETE /api/user-center/identities。最后一种登录方式的解绑按钮禁用(前端防呆,后端也有 400 兜底)。
  • i18n:login.github/discordsettings.linked.*(中英)。

验证

  • pnpm typecheck / pnpm lint(0 error)/ pnpm build 通过;/login SSG(/settings 是既有的 ƒ,非本 PR 引入)。

⚠️ 合并/开放前必须知道

  1. 先合后端 Change the article url #48 并部署,否则 /oauth/render/discord 后端还不认。
  2. 需要 Discord OAuth App(维护者建,回调 ${AUTH_URL}/api/auth/callback/discord)+ Discord 后台把 Public Client 关掉
  3. 分叉风险:本 PR 只加了 Discord 登录按钮,还没有"连接已有账号"的绑定流程(M2b)。已有 GitHub 账号的人点"用 Discord 登录"会新建独立账号。建议正式对外开放 Discord 登录前先做 M2b(绑定 + 同邮箱提示),或先只在内部冒烟。设置页的"连接"按钮也因此故意没加

🤖 Generated with Claude Code

https://claude.ai/code/session_01RtSNVtrEkCsFVHrbt4Zjgi

配合后端 Discord provider(involutionhell-backend#48):

- next.config.mjs:OAuth 回调 rewrite 从硬编码 /api/auth/callback/github 泛化为
  /api/auth/callback/:provider——否则 Discord 回调漏代理 → 404(登录跑不通的阻断项)
- 登录页加"用 Discord 登录"按钮;SignInButton 参数化 provider(header 处默认 github 不变)
- 设置页加"登录方式"区:列出已绑定身份 + 解绑(后端 M2a)。最后一种登录方式
  的解绑按钮禁用(防锁死,后端也有兜底)
- i18n:login.github/discord、settings.linked.*

暂不加"连接 Discord"按钮:绑定流程(M2b)未上线前,点它只会把用户登成新账号(分叉)。

typecheck / lint(0 error)/ build 通过;/login 仍 ● SSG。
Copilot AI review requested due to automatic review settings July 19, 2026 15:19
@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
involutionhell-github-io Ready Ready Preview, Comment Jul 19, 2026 3:29pm
website-preview Ready Ready Preview, Comment Jul 19, 2026 3:29pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@longsizhuo
longsizhuo merged commit a1f26d4 into main Jul 19, 2026
9 checks passed
longsizhuo added a commit that referenced this pull request Jul 19, 2026
#382 把 GitHub/Discord 两个按钮放在了 /login 页,但 header 的 "Sign In"
(AuthNav 里 <SignInButton /> 无 provider)仍直跳 /oauth/render/github,
用户点了就直奔 GitHub、根本看不到 Discord 选项。

改:SignInButton 不传 provider 时跳 /login 选择页;登录页两个按钮传了
provider 仍直跳对应授权。header 无 props 调用自动获得"先选后登"。

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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