Skip to content

Commit f59a90b

Browse files
fix(clerk-js): Show unverified fields if any when ToS is enabled (#5404)
Co-authored-by: panteliselef <[email protected]>
1 parent b6a4735 commit f59a90b

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed

.changeset/all-buckets-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Fix issue where unverified field weren't showing up when ToS was enabled

packages/clerk-js/bundlewatch.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"files": [
3-
{ "path": "./dist/clerk.js", "maxSize": "577.5kB" },
3+
{ "path": "./dist/clerk.js", "maxSize": "577.51kB" },
44
{ "path": "./dist/clerk.browser.js", "maxSize": "78.5kB" },
55
{ "path": "./dist/clerk.headless.js", "maxSize": "51KB" },
66
{ "path": "./dist/ui-common*.js", "maxSize": "94KB" },
@@ -12,7 +12,7 @@
1212
{ "path": "./dist/organizationswitcher*.js", "maxSize": "5KB" },
1313
{ "path": "./dist/organizationlist*.js", "maxSize": "5.5KB" },
1414
{ "path": "./dist/signin*.js", "maxSize": "12.4KB" },
15-
{ "path": "./dist/signup*.js", "maxSize": "6.55KB" },
15+
{ "path": "./dist/signup*.js", "maxSize": "6.57KB" },
1616
{ "path": "./dist/userbutton*.js", "maxSize": "5KB" },
1717
{ "path": "./dist/userprofile*.js", "maxSize": "15KB" },
1818
{ "path": "./dist/userverification*.js", "maxSize": "5KB" },

packages/clerk-js/src/ui/components/SignUp/SignUpContinue.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function SignUpContinueInternal() {
5959
label: localizationKeys('formFieldLabel__lastName'),
6060
placeholder: localizationKeys('formFieldInputPlaceholder__lastName'),
6161
}),
62-
emailAddress: useFormControl('emailAddress', initialValues.emailAddress || '', {
62+
emailAddress: useFormControl('emailAddress', initialValues.emailAddress || signUp.emailAddress || '', {
6363
type: 'email',
6464
label: localizationKeys('formFieldLabel__emailAddress'),
6565
placeholder: localizationKeys('formFieldInputPlaceholder__emailAddress'),
@@ -91,8 +91,13 @@ function SignUpContinueInternal() {
9191
} as const;
9292

9393
const onlyLegalConsentMissing = useMemo(
94-
() => signUp.missingFields && signUp.missingFields.length === 1 && signUp.missingFields[0] === 'legal_accepted',
95-
[signUp.missingFields],
94+
() =>
95+
signUp.missingFields &&
96+
signUp.missingFields.length === 1 &&
97+
signUp.missingFields[0] === 'legal_accepted' &&
98+
signUp.unverifiedFields &&
99+
signUp.unverifiedFields.length === 0,
100+
[signUp.missingFields, signUp.unverifiedFields],
96101
);
97102

98103
useEffect(() => {

packages/clerk-js/src/ui/components/SignUp/__tests__/SignUpContinue.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,23 @@ describe('SignUpContinue', () => {
9696
screen.getByText(/Privacy Policy/i);
9797
});
9898

99+
it('renders the component if there is a persisted sign up and legal accepted is missing and email address is unverified', async () => {
100+
const { wrapper } = await createFixtures(f => {
101+
f.withEmailAddress({ required: true });
102+
f.withPassword({ required: true });
103+
f.startSignUpWithMissingLegalAcceptedAndUnverifiedFields();
104+
f.withLegalConsent();
105+
f.withTermsPrivacyPolicyUrls({
106+
privacyPolicy: 'https://clerk.dev/privacy',
107+
termsOfService: 'https://clerk.dev/tos',
108+
});
109+
});
110+
const screen = render(<SignUpContinue />, { wrapper });
111+
expect(screen.queryByText(/email address/i)).toBeInTheDocument();
112+
expect(screen.queryByText(/Privacy Policy/i)).toBeInTheDocument();
113+
expect(screen.queryByText(/Terms Of Service/i)).toBeInTheDocument();
114+
});
115+
99116
it.each(OAUTH_PROVIDERS)('shows the "Continue with $name" social OAuth button', async ({ provider, name }) => {
100117
const { wrapper } = await createFixtures(f => {
101118
f.withEmailAddress({ required: true });

packages/clerk-js/src/ui/utils/test/fixtureHelpers.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ const createSignUpFixtureHelpers = (baseClient: ClientJSON) => {
251251
},
252252
},
253253
missing_fields: [],
254+
unverified_fields: emailVerificationStatus === 'unverified' ? ['email_address'] : [],
254255
} as SignUpJSON;
255256
};
256257

@@ -272,7 +273,23 @@ const createSignUpFixtureHelpers = (baseClient: ClientJSON) => {
272273
} as SignUpJSON;
273274
};
274275

275-
return { startSignUpWithEmailAddress, startSignUpWithPhoneNumber, startSignUpWithMissingLegalAccepted };
276+
const startSignUpWithMissingLegalAcceptedAndUnverifiedFields = (emailAddress = '[email protected]') => {
277+
baseClient.sign_up = {
278+
id: 'sua_2HseAXFGN12eqlwARPMxyyUa9o9',
279+
status: 'missing_requirements',
280+
legal_accepted_at: null,
281+
missing_fields: ['legal_accepted'],
282+
email_address: emailAddress,
283+
unverified_fields: ['email_address'],
284+
} as SignUpJSON;
285+
};
286+
287+
return {
288+
startSignUpWithEmailAddress,
289+
startSignUpWithPhoneNumber,
290+
startSignUpWithMissingLegalAccepted,
291+
startSignUpWithMissingLegalAcceptedAndUnverifiedFields,
292+
};
276293
};
277294

278295
const createAuthConfigFixtureHelpers = (environment: EnvironmentJSON) => {

0 commit comments

Comments
 (0)