Skip to content
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): Propagate redirectUrl when continuing sign up with missing identifier #4542

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions packages/clerk-js/src/ui/components/SignUp/SignUpContinue.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useClerk } from '@clerk/shared/react';
import React, { useMemo } from 'react';

import { buildSSOCallbackURL } from '../../common';
import { useCoreSignUp, useEnvironment, useSignUpContext } from '../../contexts';
import { descriptors, Flex, Flow, localizationKeys } from '../../customizables';
import {
Expand Down Expand Up @@ -37,6 +38,7 @@ function _SignUpContinue() {
const [activeCommIdentifierType, setActiveCommIdentifierType] = React.useState<ActiveIdentifier>(
getInitialActiveIdentifier(attributes, userSettings.signUp.progressive),
);
const ctx = useSignUpContext();

// TODO: This form should be shared between SignUpStart and SignUpContinue
const formState = {
Expand Down Expand Up @@ -150,6 +152,9 @@ function _SignUpContinue() {
card.setLoading();
card.setError(undefined);

const redirectUrl = buildSSOCallbackURL(ctx, displayConfig.signUpUrl);
Copy link
Member

Choose a reason for hiding this comment

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

I see that we do this constantly, does it make sense to move it inside useSignUpContext ?

const redirectUrlComplete = ctx.afterSignUpUrl || '/';
Copy link
Member

Choose a reason for hiding this comment

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

🙃 I believe we already properly resolve this inside the RedirectUrls class

Suggested change
const redirectUrlComplete = ctx.afterSignUpUrl || '/';
const redirectUrlComplete = ctx.afterSignUpUrl


return signUp
.update(buildRequest(fieldsToSubmit))
.then(res =>
Expand All @@ -159,6 +164,8 @@ function _SignUpContinue() {
verifyPhonePath: './verify-phone-number',
handleComplete: () => clerk.setActive({ session: res.createdSessionId, redirectUrl: afterSignUpUrl }),
navigate,
redirectUrl,
redirectUrlComplete,
}),
)
.catch(err => handleError(err, fieldsToSubmit, card.setError))
Expand Down
Loading