Skip to content

Commit aca3fac

Browse files
committed
Check if email addresses are enabled
1 parent 49e435e commit aca3fac

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

packages/clerk-js/src/core/clerk.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import {
1414
disabledAllAPIKeysFeatures,
1515
disabledAllBillingFeatures,
16+
disabledEmailAddressAttribute,
1617
disabledOrganizationAPIKeysFeature,
1718
disabledOrganizationsFeature,
1819
disabledSelfServeSSOFeature,
@@ -59,6 +60,7 @@ import type {
5960
__internal_AttemptToEnableEnvironmentSettingResult,
6061
__internal_CheckoutProps,
6162
__internal_EnableOrganizationsPromptProps,
63+
__internal_OAuthConsentProps,
6264
__internal_PlanDetailsProps,
6365
__internal_SubscriptionDetailsProps,
6466
__internal_UserVerificationModalProps,
@@ -96,7 +98,6 @@ import type {
9698
LoadedClerk,
9799
NavigateOptions,
98100
OAuthApplicationNamespace,
99-
__internal_OAuthConsentProps,
100101
OrganizationListProps,
101102
OrganizationProfileProps,
102103
OrganizationResource,
@@ -211,6 +212,8 @@ const CANNOT_RENDER_API_KEYS_DISABLED_ERROR_CODE = 'cannot_render_api_keys_disab
211212
const CANNOT_RENDER_API_KEYS_USER_DISABLED_ERROR_CODE = 'cannot_render_api_keys_user_disabled';
212213
const CANNOT_RENDER_API_KEYS_ORG_DISABLED_ERROR_CODE = 'cannot_render_api_keys_org_disabled';
213214
const CANNOT_RENDER_SELF_SERVE_SSO_DISABLED_ERROR_CODE = 'cannot_render_self_serve_sso_disabled';
215+
const CANNOT_RENDER_CONFIGURE_SSO_EMAIL_ADDRESS_DISABLED_ERROR_CODE =
216+
'cannot_render_configure_sso_email_address_disabled';
214217
const defaultOptions: ClerkOptions = {
215218
polling: true,
216219
standardBrowser: true,
@@ -1469,6 +1472,15 @@ export class Clerk implements ClerkInterface {
14691472
return;
14701473
}
14711474

1475+
if (disabledEmailAddressAttribute(this, this.environment)) {
1476+
if (this.#instanceType === 'development') {
1477+
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenEmailAddressDisabled, {
1478+
code: CANNOT_RENDER_CONFIGURE_SSO_EMAIL_ADDRESS_DISABLED_ERROR_CODE,
1479+
});
1480+
}
1481+
return;
1482+
}
1483+
14721484
this.assertComponentsReady(this.#clerkUI);
14731485
const component = 'ConfigureSSO';
14741486
void this.#clerkUI

packages/shared/src/internal/clerk-js/componentGuards.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ export const disabledAllAPIKeysFeatures: ComponentGuard = (_, environment) => {
4949
export const disabledSelfServeSSOFeature: ComponentGuard = (_, environment) => {
5050
return !environment?.userSettings.enterpriseSSO.self_serve_sso;
5151
};
52+
53+
export const disabledEmailAddressAttribute: ComponentGuard = (_, environment) => {
54+
return !environment?.userSettings.attributes.email_address?.enabled;
55+
};

packages/shared/src/internal/clerk-js/warnings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ const warnings = {
6666
'<OAuthConsent/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.',
6767
cannotRenderConfigureSSOComponentWhenDisabled:
6868
'The <ConfigureSSO/> component cannot be rendered when self-serve SSO is disabled. Visit `https://dashboard.clerk.com` to enable the feature. Since self-serve SSO is disabled, this is no-op.',
69+
cannotRenderConfigureSSOComponentWhenEmailAddressDisabled:
70+
'The <ConfigureSSO/> component cannot be rendered when email addresses are disabled on the instance. Visit `https://dashboard.clerk.com` to enable email addresses. Since email addresses are disabled, this is no-op.',
6971
};
7072

7173
type SerializableWarnings = Serializable<typeof warnings>;

0 commit comments

Comments
 (0)