Skip to content

Commit 52c86a4

Browse files
committed
Create connection for organization
1 parent c2f6b2f commit 52c86a4

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

packages/ui/src/components/ConfigureSSO/ConfigureSSO.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ const AuthenticatedContent = withCoreUserGuard(() => {
5252
const { organizationSettings } = useEnvironment();
5353
const { parsedOptions } = useAppearance();
5454
const hasLogo = Boolean(parsedOptions.logoImageUrl || logoImageUrl);
55+
const { organization } = useOrganization();
5556

5657
// Gate the entire wizard behind the org-level permission. When the
5758
// user can't manage enterprise connections, we still render the
5859
// outer sidebar/title chrome but replace the wizard with a
5960
// permissions-error message so the layout stays consistent
60-
const canManageEnterpriseConnections = useProtect({
61-
permission: 'org:sys_enterprise_connections:manage',
62-
});
61+
const canManageEnterpriseConnections =
62+
!!organization &&
63+
useProtect({
64+
permission: 'org:sys_enterprise_connections:manage',
65+
});
6366

6467
const {
6568
data: enterpriseConnections,
@@ -69,7 +72,7 @@ const AuthenticatedContent = withCoreUserGuard(() => {
6972
deleteEnterpriseConnection,
7073
revalidate: revalidateEnterpriseConnections,
7174
} = __internal_useUserEnterpriseConnections({
72-
enabled: canManageEnterpriseConnections,
75+
enabled: true,
7376
});
7477
// Currently FAPI only supports one enterprise connection per user
7578
const enterpriseConnection = enterpriseConnections?.[0];
@@ -148,7 +151,7 @@ const AuthenticatedContent = withCoreUserGuard(() => {
148151
flex: 1,
149152
})}
150153
>
151-
{canManageEnterpriseConnections ? (
154+
{canManageEnterpriseConnections || !organization ? (
152155
<ConfigureSSOFlowProvider
153156
enterpriseConnection={enterpriseConnection}
154157
isLoading={isLoadingEnterpriseConnections}

packages/ui/src/components/ConfigureSSO/steps/ConfigureCreateAppStep.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useUser } from '@clerk/shared/react';
1+
import { useOrganization, useUser } from '@clerk/shared/react';
22
import React from 'react';
33

44
import { Box, Button, Col, descriptors, Flex, Flow, Icon, Input, Spinner, Text } from '@/customizables';
@@ -19,6 +19,7 @@ export const ConfigureCreateApp = (): JSX.Element => {
1919
useConfigureSSOFlow();
2020
const { user } = useUser();
2121
const card = useCardState();
22+
const { organization } = useOrganization();
2223

2324
const primaryEmail = user?.primaryEmailAddress?.emailAddress ?? '';
2425
const emailDomain = getEmailDomain(primaryEmail);
@@ -51,6 +52,7 @@ export const ConfigureCreateApp = (): JSX.Element => {
5152
createEnterpriseConnection({
5253
provider: selectedProvider,
5354
name: emailDomain,
55+
organizationId: organization?.id,
5456
})
5557
.catch(err => handleError(err as Error, [], card.setError))
5658
.finally(() => setIsCreating(false));

0 commit comments

Comments
 (0)