From fb3971453e911e5e1d43b2d144207f439adefb88 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Tue, 27 Oct 2026 17:07:26 -0400 Subject: [PATCH 1/2] refactor(mosaic): use the shared enterprise check for adding passkeys --- .changeset/mosaic-passkeys-shared-enterprise-check.md | 2 ++ .../user-profile-passkeys-section.model.ts | 7 ++----- .../utils/__tests__/allows-identification-creation.test.ts | 7 ++++++- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changeset/mosaic-passkeys-shared-enterprise-check.md diff --git a/.changeset/mosaic-passkeys-shared-enterprise-check.md b/.changeset/mosaic-passkeys-shared-enterprise-check.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/mosaic-passkeys-shared-enterprise-check.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/mosaic/src/features/user-profile/user-profile-passkeys-section/user-profile-passkeys-section.model.ts b/packages/mosaic/src/features/user-profile/user-profile-passkeys-section/user-profile-passkeys-section.model.ts index ee13cecf819..3482651482e 100644 --- a/packages/mosaic/src/features/user-profile/user-profile-passkeys-section/user-profile-passkeys-section.model.ts +++ b/packages/mosaic/src/features/user-profile/user-profile-passkeys-section/user-profile-passkeys-section.model.ts @@ -6,6 +6,7 @@ import { FormSubmitError } from '../../../components/form'; import { getMosaicEnvironment, useMosaicEnvironment } from '../../../hooks/use-mosaic-environment'; import { useNow } from '../../../hooks/use-now'; import { fill, useLocale, useMessages } from '../../../localization'; +import { allowsIdentificationCreation } from '../../../utils/allows-identification-creation'; import { save, SaveError } from '../../../utils/errors'; import type { ReverificationController } from '../../reverification'; import { useReverificationFlow } from '../../reverification'; @@ -76,11 +77,7 @@ function getPasskeysProjection( return projectPasskeys({ passkeys: user.passkeys, enabled: Boolean(environment.userSettings.attributes.passkey?.enabled), - allowIdentificationCreation: - !environment.userSettings.enterpriseSSO.enabled || - !user.enterpriseAccounts.some( - account => account.active && account.enterpriseConnection?.disableAdditionalIdentifications, - ), + allowIdentificationCreation: allowsIdentificationCreation(user, environment.userSettings.enterpriseSSO), isSatellite, }); } diff --git a/packages/mosaic/src/utils/__tests__/allows-identification-creation.test.ts b/packages/mosaic/src/utils/__tests__/allows-identification-creation.test.ts index fb805ba8201..9fde819ce73 100644 --- a/packages/mosaic/src/utils/__tests__/allows-identification-creation.test.ts +++ b/packages/mosaic/src/utils/__tests__/allows-identification-creation.test.ts @@ -12,7 +12,12 @@ describe('allowsIdentificationCreation', () => { expect(allowsIdentificationCreation(blocked, enterpriseSSO)).toBe(false); }); - it('allows creation when the enterprise connection is inactive or enterprise SSO is off', () => { + it('allows creation when the enterprise connection permits it, is inactive, or enterprise SSO is off', () => { + const permitted = { + enterpriseAccounts: [{ active: true, enterpriseConnection: { disableAdditionalIdentifications: false } }], + }; + expect(allowsIdentificationCreation(permitted, enterpriseSSO)).toBe(true); + const inactive = { enterpriseAccounts: [{ active: false, enterpriseConnection: { disableAdditionalIdentifications: true } }], }; From d2bb18deb2a2466b170901bd4421c6f5e468fb04 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Tue, 27 Oct 2026 18:57:13 -0400 Subject: [PATCH 2/2] refactor(mosaic): use the shared enterprise check for adding emails and phone numbers --- .../user-profile/user-profile-contact.utils.ts | 11 +---------- .../user-profile-email-section.model.ts | 5 +++-- .../user-profile-phone-section.model.ts | 5 +++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/mosaic/src/features/user-profile/user-profile-contact.utils.ts b/packages/mosaic/src/features/user-profile/user-profile-contact.utils.ts index 2c720a69a7e..56b2f78d083 100644 --- a/packages/mosaic/src/features/user-profile/user-profile-contact.utils.ts +++ b/packages/mosaic/src/features/user-profile/user-profile-contact.utils.ts @@ -1,4 +1,4 @@ -import type { AttributeData, UserResource, VerificationResource } from '@clerk/shared/types'; +import type { AttributeData, VerificationResource } from '@clerk/shared/types'; import { isAttributeAvailable } from './user-profile.utils'; import type { UserProfileContact } from './user-profile-contact.types'; @@ -20,15 +20,6 @@ export function toContactAccess( return { show: available && (canCreate || count > 0), canCreate, canRemove: mutable }; } -export function canAddIdentifications(user: UserResource, enterpriseSSOEnabled: boolean): boolean { - return ( - !enterpriseSSOEnabled || - !user.enterpriseAccounts.some( - account => account.active && account.enterpriseConnection?.disableAdditionalIdentifications, - ) - ); -} - export function byId(items: T[], id: string, kind: string): T { const item = items.find(item => item.id === id); if (!item) { diff --git a/packages/mosaic/src/features/user-profile/user-profile-email-section/user-profile-email-section.model.ts b/packages/mosaic/src/features/user-profile/user-profile-email-section/user-profile-email-section.model.ts index d72a5ef20b6..b94eb88cfd5 100644 --- a/packages/mosaic/src/features/user-profile/user-profile-email-section/user-profile-email-section.model.ts +++ b/packages/mosaic/src/features/user-profile/user-profile-email-section/user-profile-email-section.model.ts @@ -3,10 +3,11 @@ import type { EmailAddressResource, UserResource } from '@clerk/shared/types'; import type { MosaicRouter } from '../../../hooks/use-mosaic-router'; import { useMosaicRouter } from '../../../hooks/use-mosaic-router'; +import { allowsIdentificationCreation } from '../../../utils/allows-identification-creation'; import { save } from '../../../utils/errors'; import { useReverificationFlow } from '../../reverification'; import type { UserProfileEmailVerification, UserProfileEmailVerifier } from '../user-profile-contact.types'; -import { byId, canAddIdentifications, toContactAccess, toContacts } from '../user-profile-contact.utils'; +import { byId, toContactAccess, toContacts } from '../user-profile-contact.utils'; import { useUserProfileUserModel } from '../user-profile-user.model'; import type { UserProfileAddEmailField } from './user-profile-add-email.controller'; import type { UserProfileEmailSectionModel } from './user-profile-email-section.types'; @@ -104,7 +105,7 @@ export function useUserProfileEmailSectionModel(): UserProfileEmailSectionModel const access = toContactAccess( attributes.email_address, user.emailAddresses.length, - canAddIdentifications(user, enterpriseSSO.enabled), + allowsIdentificationCreation(user, enterpriseSSO), ); if (!access.show) { diff --git a/packages/mosaic/src/features/user-profile/user-profile-phone-section/user-profile-phone-section.model.ts b/packages/mosaic/src/features/user-profile/user-profile-phone-section/user-profile-phone-section.model.ts index aec4af43bfb..640c081b86b 100644 --- a/packages/mosaic/src/features/user-profile/user-profile-phone-section/user-profile-phone-section.model.ts +++ b/packages/mosaic/src/features/user-profile/user-profile-phone-section/user-profile-phone-section.model.ts @@ -2,10 +2,11 @@ import { useClerk } from '@clerk/shared/react'; import type { PhoneNumberResource, UserResource } from '@clerk/shared/types'; import { toCountryIso } from '../../../components/phone-input'; +import { allowsIdentificationCreation } from '../../../utils/allows-identification-creation'; import { save } from '../../../utils/errors'; import { useReverificationFlow } from '../../reverification'; import type { UserProfilePhoneVerifier } from '../user-profile-contact.types'; -import { byId, canAddIdentifications, toContactAccess, toContacts } from '../user-profile-contact.utils'; +import { byId, toContactAccess, toContacts } from '../user-profile-contact.utils'; import { useUserProfileUserModel } from '../user-profile-user.model'; import type { UserProfileAddPhoneField } from './user-profile-add-phone.controller'; import type { UserProfilePhoneSectionModel } from './user-profile-phone-section.types'; @@ -40,7 +41,7 @@ export function useUserProfilePhoneSectionModel(): UserProfilePhoneSectionModel const access = toContactAccess( attributes.phone_number, user.phoneNumbers.length, - canAddIdentifications(user, enterpriseSSO.enabled), + allowsIdentificationCreation(user, enterpriseSSO), ); if (!access.show) {