Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 469
fix(ui): populate enterprise SSO redirect urls when continuing a sign-up#9449
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| '@clerk/shared': patch | ||
| '@clerk/ui': patch | ||
| --- | ||
| Fix sign-ups that continue into an enterprise SSO connection failing with `invalid_redirect_url` ("Redirect url invalid") instead of redirecting to the identity provider. | ||
| A sign-up does not always know it requires `enterprise_sso` when the form is first submitted — the requirement appears once the identity behind the sign-up is resolved, which can happen several steps later. Whichever step was active at that point performed the hand-off to the identity provider, and most of them did so without the redirect URLs it requires, so the request was rejected and the sign-up dead-ended with no way to continue. Retrying reproduced it every time. Flows that reached SSO directly from the first sign-up form were unaffected, which is why this only showed up on some sign-ups. | ||
| The redirect URLs are now derived from the sign-up context wherever the flow continues, so the hand-off works from every step: the continue form, email-link and code verification, and the verification step that precedes them. | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -22,8 +22,8 @@ export const completeSignUpFlow = ({ | ||||
| continuePath, | ||||
| navigate, | ||||
| handleComplete, | ||||
| redirectUrl = '', | ||||
| redirectUrlComplete = '', | ||||
| redirectUrl, | ||||
| redirectUrlComplete, | ||||
| oidcPrompt, | ||||
| }: CompleteSignUpFlowProps): Promise<unknown> | undefined => { | ||||
| if (signUp.status === 'complete') { | ||||
| @@ -32,6 +32,13 @@ export const completeSignUpFlow = ({ | ||||
| return handleComplete && handleComplete(); | ||||
| } else if (signUp.status === 'missing_requirements') { | ||||
| if (signUp.missingFields.some(mf => mf === 'enterprise_sso')) { | ||||
| // FAPI rejects an empty redirect url, which reaches the user as a dead end rather than the caller as a bug. | ||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ||||
| if (!redirectUrl || !redirectUrlComplete) { | ||||
| throw new Error( | ||||
| 'completeSignUpFlow: `redirectUrl` and `redirectUrlComplete` are required to continue a sign-up that is missing `enterprise_sso`.', | ||||
| ); | ||||
| } | ||||
| return signUp.authenticateWithRedirect({ | ||||
| strategy: 'enterprise_sso', | ||||
| redirectUrl, | ||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -14,14 +14,16 @@ import { EmailLinkStatusCard } from './EmailLinkStatusCard'; | ||||
| export type EmailLinkVerifyProps = { | ||||
| redirectUrlComplete?: string; | ||||
| redirectUrl?: string; | ||||
| /** SSO callback url, required only when the verified sign-up still has to hand off to an enterprise connection. */ | ||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ||||
| ssoCallbackUrl?: string; | ||||
| verifyEmailPath?: string; | ||||
| verifyPhonePath?: string; | ||||
| continuePath?: string; | ||||
| texts: Record<EmailLinkUIStatus, { title: LocalizationKey; subtitle: LocalizationKey }>; | ||||
| }; | ||||
| export const EmailLinkVerify = (props: EmailLinkVerifyProps) => { | ||||
| const { redirectUrl, redirectUrlComplete, verifyEmailPath, verifyPhonePath, continuePath } = props; | ||||
| const { redirectUrl, redirectUrlComplete, ssoCallbackUrl, verifyEmailPath, verifyPhonePath, continuePath } = props; | ||||
Comment on lines
25
to
+26
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bashset -euo pipefail
# Inspect the established JSX return-type convention before selecting the annotation.
rg -n --glob '*.tsx''export const [A-Za-z0-9_]+.*: (React\.)?JSX\.Element' packages/ui/src | head -n 50
fd -a -t f '^tsconfig.*\.json$'. -x rg -n '"jsx"|"jsxImportSource"' {}Repository: clerk/javascript Length of output: 8288 🏁 Script executed: #!/bin/bashset -euo pipefail
printf'%s\n''--- EmailLinkVerify.tsx ---'
cat -n packages/ui/src/common/EmailLinkVerify.tsx
printf'%s\n''--- nearby common component return types ---'
rg -n -U --glob '*.tsx''export const [A-Za-z0-9_]+[\s\S]{0,120}: (JSX\.Element|React\.JSX\.Element)' packages/ui/src/common | head -n 80
printf'%s\n''--- UI TypeScript configuration ---'
fd -a -t f '^tsconfig.*\.json$' packages/ui -x sh -c 'echo "--- $1"; cat "$1"' sh {} | head -n 240Repository: clerk/javascript Length of output: 3826 🏁 Script executed: #!/bin/bashset -euo pipefail
printf'%s\n''--- JSX return-type usage in common components ---'
rg -n --glob '*.tsx''export const .*: (React\.)?JSX\.Element' packages/ui/src/common ||trueprintf'%s\n''--- relevant UI TypeScript configs ---'
fd -a -t f '^tsconfig.*\.json$' packages/ui -x sh -c ' echo "--- $1" rg -n "\"jsx\"|\"jsxImportSource\"|\"types\"|\"extends\"" "$1" || true' sh {}
printf'%s\n''--- explicit-return ESLint rules ---'
rg -n 'explicit-function-return-type|explicit-module-boundary-types'. --glob '*eslint*' --glob '*package.json'| head -n 80 ||trueRepository: clerk/javascript Length of output: 565 Add an explicit The repository uses 🤖 Prompt for AI AgentsSource: Coding guidelines | ||||
| const { handleEmailLinkVerification } = useClerk(); | ||||
| const { navigate } = useRouter(); | ||||
| const signUp = useCoreSignUp(); | ||||
| @@ -50,6 +52,8 @@ export const EmailLinkVerify = (props: EmailLinkVerifyProps) => { | ||||
| protectCheckPath: '../protect-check', | ||||
| continuePath, | ||||
| navigate, | ||||
| redirectUrl: ssoCallbackUrl, | ||||
| redirectUrlComplete: redirectUrlComplete || '/', | ||||
| }); | ||||
| } catch (err: any) { | ||||
| if ( | ||||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.