Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hot-cats-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Fix issue where the SSO callback URL was incorrectly generated when using the transfer flow within a modal.
10 changes: 9 additions & 1 deletion packages/clerk-js/src/ui/common/__tests__/redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,16 @@ describe('buildSSOCallbackURL(ctx, baseUrl)', () => {
).toBe('http://test.host/#/sso-callback?redirect_url=%2Ffoo');

// Custom SSO callback URL in the context
expect(buildSSOCallbackURL({ ssoCallbackUrl: 'http://test.host/ctx-sso-callback' })).toBe(
expect(buildSSOCallbackURL({ isCombinedFlow: true, ssoCallbackUrl: 'http://test.host/ctx-sso-callback' })).toBe(
'http://test.host/ctx-sso-callback',
);
// Does not use SSO callback URL from context when routing is virtual
expect(
buildSSOCallbackURL({
isCombinedFlow: true,
ssoCallbackUrl: 'http://test.host/ctx-sso-callback',
routing: 'virtual',
}),
).toBe('http://localhost/#/sso-callback');
});
});
7 changes: 4 additions & 3 deletions packages/clerk-js/src/ui/common/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ export function buildSSOCallbackURL(
ctx: Partial<SignInContextType | SignUpContextType>,
baseUrl: string | undefined = '',
): string {
const { routing, authQueryString, path } = ctx;
// If the context contains an SSO callback URL, use it instead of building a new one, as it likely contains the
// combined flow path.
if ('ssoCallbackUrl' in ctx && ctx.ssoCallbackUrl) {
// combined flow path. However, if the routing is virtual, the callback URL from context will not have factored in
// baseUrl, so we fallback to buildRedirectUrl instead.
if (ctx.ssoCallbackUrl && ctx.isCombinedFlow && routing !== 'virtual') {
return ctx.ssoCallbackUrl;
}
const { routing, authQueryString, path } = ctx;
return buildRedirectUrl({
routing,
baseUrl,
Expand Down