-
Notifications
You must be signed in to change notification settings - Fork 403
fix(clerk-js): Do not treat phone_number as optional if used as identifier #5992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(clerk-js): Do not treat phone_number as optional if used as identifier #5992
Conversation
🦋 Changeset detectedLatest commit: f78f00f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@clerk/agent-toolkit
@clerk/chrome-extension
@clerk/astro
@clerk/clerk-js
@clerk/backend
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/tanstack-react-start
@clerk/testing
@clerk/shared
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures the combined sign-up flow correctly handles phone numbers when they’re marked optional and adds basic unit tests for the handleCombinedFlowTransfer function.
- Extend
hasOptionalFieldsto acceptidentifierAttributeand ignorephone_numberwhenphoneNumberis used as the identifier. - Update the combined flow transfer logic to call the new
hasOptionalFieldssignature. - Add unit tests covering phone-number identifier flows and basic
hasOptionalFieldsbehavior.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/clerk-js/src/ui/components/SignIn/handleCombinedFlowTransfer.ts | Update optional-fields logic to consider identifierAttribute, export hasOptionalFields, and skip phone_number when appropriate. |
| packages/clerk-js/src/ui/components/SignIn/tests/handleCombinedFlowTransfer.test.ts | Add tests for phone-number identifier, passwordEnabled, username cases, and hasOptionalFields scenarios. |
| .changeset/little-wings-bathe.md | Add patch changeset describing the fix for treating phone_number as required when used as an identifier. |
Comments suppressed due to low confidence (3)
packages/clerk-js/src/ui/components/SignIn/tests/handleCombinedFlowTransfer.test.ts:151
- Add a test case to verify that
hasOptionalFieldsexcludes 'email_address' whenidentifierAttributeis 'emailAddress'.
describe('hasOptionalFields', () => {
packages/clerk-js/src/ui/components/SignIn/tests/handleCombinedFlowTransfer.test.ts:151
- Add tests to ensure fields starting with 'oauth_' or 'web3_', and values 'enterprise_sso'/'saml', are properly filtered out.
describe('hasOptionalFields', () => {
packages/clerk-js/src/ui/components/SignIn/handleCombinedFlowTransfer.ts:113
- Also exclude 'email_address' when
identifierAttributeis 'emailAddress' to ensure email identifiers aren’t counted as optional and don’t block the direct flow.
// If a phone number is used as the identifier, we don't need to consider the phone_number field.
packages/clerk-js/src/ui/components/SignIn/handleCombinedFlowTransfer.ts
Show resolved
Hide resolved
packages/clerk-js/src/ui/components/SignIn/handleCombinedFlowTransfer.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
Description
This PR fixes an issue where the combined flow wouldn't trigger correctly when invoked with a phone number while phone number was an optional field. It resolves the issue by treating phone_number as a non-optional field when a phone number identifier is used. Additionally, it adds some very, very basic unit tests for the
handleCombinedFlowTransferfunction.For context, we don't automatically convert sign ins to sign ups in the combined flow if there are possible optional fields that the user might want to complete. Before this PR,
phone_numberwas an optional field. If the user tried to sign in with a phone number not associated with an account, we would considerphone_numberan optional field, and redirect to thecreatestep. This was unnecessary since the user already provided a phone number.Fixes SDKI-1020
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change