Skip to content

Commit d0f9eaf

Browse files
committed
fixup! fix(clerk-js): require email or phone when password field is visible
1 parent a378587 commit d0f9eaf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/clerk-js/src/ui/components/SignUp/signUpFormHelpers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function getEmailAddressField({
192192
return;
193193
}
194194

195-
const { emailShouldBeRequired } = determineRequiredCommunicationMethod(attributes);
195+
const { emailShouldBeRequired } = determineRequiredIdentifier(attributes);
196196

197197
return {
198198
required: emailShouldBeRequired,
@@ -324,15 +324,15 @@ const outcomePredicates: Record<Outcome, ((ctx: Context) => boolean)[]> = {
324324
mirrorServer: [
325325
// If password is not required, then field requirements are determined by the server.
326326
ctx => !ctx.passwordRequired,
327-
// If any of the communication methods are already required by the server, then we don't need to do anything.
327+
// If any of the identifiers are already required by the server, then we don't need to do anything.
328328
ctx => ctx.email.required || ctx.phone.required || (ctx.username.required && ctx.username.firstFactor),
329329
],
330330
none: [
331-
// If none of the communication methods are enabled, then none can be required.
331+
// If none of the identifiers are enabled, then none can be required.
332332
ctx => !ctx.email.enabled && !ctx.phone.enabled && !ctx.username.enabled,
333333
],
334334
email: [
335-
// If email is the only enabled communication method, it should be required.
335+
// If email is the only enabled identifier, it should be required.
336336
ctx => ctx.email.enabled && !ctx.phone.enabled && !ctx.username.enabled,
337337
// If email is enabled but not required, and phone is enabled and not required, then email should be required.
338338
ctx => ctx.email.enabled && !ctx.email.required && ctx.phone.enabled && !ctx.phone.required,
@@ -364,7 +364,7 @@ const outcomePredicates: Record<Outcome, ((ctx: Context) => boolean)[]> = {
364364
* When password is required, we need to ensure at least one identifier
365365
* (email, phone, or username) is also required
366366
*/
367-
export function determineRequiredCommunicationMethod(attributes: Partial<Attributes>): {
367+
export function determineRequiredIdentifier(attributes: Partial<Attributes>): {
368368
emailShouldBeRequired: boolean;
369369
phoneShouldBeRequired: boolean;
370370
usernameShouldBeRequired: boolean;
@@ -410,7 +410,7 @@ export function determineRequiredCommunicationMethod(attributes: Partial<Attribu
410410
const phoneShouldBeRequired = outcomeMet('phone');
411411
const usernameShouldBeRequired = outcomeMet('username');
412412

413-
// If password is required and no communication method is enabled, then email is the default.
413+
// If password is required and no identifier is enabled, then email is the default.
414414
if (ctx.passwordRequired && !emailShouldBeRequired && !phoneShouldBeRequired && !usernameShouldBeRequired) {
415415
return {
416416
emailShouldBeRequired: true,

0 commit comments

Comments
 (0)