Expose error/status callbacks on the prebuilt <SignIn /> component (e.g. incorrect password, rate limiting)

未关闭
#9,770 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
react, typescript

调研方向

从 @clerk/clerk-react 中预构建的 入口点开始,跟踪其内部表单提交如何处理失败。检查 ClerkAPIError[] 以及 form_password_incorrect 和 too_many_requests 等 code 的表示方式,然后确定失败登录尝试所需的 callback 行为和覆盖范围。

由索引模型根据 Issue 内容生成。

描述

Is your feature request related to a problem?

The prebuilt <SignIn /> component (@clerk/clerk-react) handles the full sign-in flow internally but doesn't expose any way to observe failures — incorrect password, rate limiting (429s), locked accounts, etc. There's no onError prop, no emitted event, and no documented way to read the failure reason from useSignIn() when the failure happened inside the component's own internal form submission (not one we drive ourselves).

As a workaround, we've had to monkey-patch window.fetch to sniff HTTP status codes for requests to our Clerk FAPI domain, just to detect a 429 and show a "too many attempts, retry in Ns" banner:

window.fetch = async (...args) => {
  const response = await originalFetch(...args);
  if (url.includes(CLERK_DOMAIN) && response.status === 429) {
    // surface a rate-limit banner
  }
  return response;
};

This is fragile (breaks on any internal FAPI change), duplicated per-app, and can't distinguish error reasons (wrong password vs. locked vs. rate-limited) — only status codes.

Describe the solution you'd like

An onError (or onStatusChange) prop on <SignIn /> that fires with Clerk's structured error info (e.g. ClerkAPIError[] with codes like form_password_incorrect, too_many_requests) whenever an internal sign-in attempt fails — without requiring us to reimplement the form via the headless useSignIn() hook just to get error visibility.

Describe alternatives you've considered

  • Rebuilding the whole sign-in form with useSignIn() to get error access — loses all the built-in UI/appearance theming <SignIn /> gives us for free.
  • Patching window.fetch — fragile, non-public API surface, no error-code granularity.

Happy to contribute a PR if maintainers can point at the right place to emit this.

主要语言
TypeScript
星标
1.8k
派生
472
平均合并
2 天 8 小时
30 天内合并 PR
184

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

clerk/javascript 的其他 Issue

查看 clerk/javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。