diff --git a/.env.example b/.env.example index 7f63481fd..2773d6133 100644 --- a/.env.example +++ b/.env.example @@ -109,6 +109,9 @@ LINEAR_TICKETING_CLOUD_CLIENT_SECRET= # Box BOX_FILESTORAGE_CLOUD_CLIENT_ID= BOX_FILESTORAGE_CLOUD_CLIENT_SECRET= +# Onedrive +ONEDRIVE_FILESTORAGE_CLOUD_CLIENT_ID= +ONEDRIVE_FILESTORAGE_CLOUD_CLIENT_SECRET= # ================================================ diff --git a/apps/magic-link/src/hooks/useOAuth.ts b/apps/magic-link/src/hooks/useOAuth.ts index d087a761a..8af512305 100644 --- a/apps/magic-link/src/hooks/useOAuth.ts +++ b/apps/magic-link/src/hooks/useOAuth.ts @@ -14,9 +14,7 @@ type UseOAuthProps = { value: string | null; }, onSuccess: () => void; - additionalParams?: { - end_user_domain: string; - } + additionalParams?: {[key: string]: any} }; const useOAuth = ({ providerName, vertical, returnUrl, projectId, linkedUserId, additionalParams, redirectIngressUri, onSuccess }: UseOAuthProps) => { diff --git a/apps/magic-link/src/lib/ProviderModal.tsx b/apps/magic-link/src/lib/ProviderModal.tsx index b3b3b0217..d2406c082 100644 --- a/apps/magic-link/src/lib/ProviderModal.tsx +++ b/apps/magic-link/src/lib/ProviderModal.tsx @@ -22,8 +22,10 @@ interface IBasicAuthFormData { } const domainFormats: { [key: string]: string } = { - microsoftdynamicssales: '{YOUR_DOMAIN}.api.crm3.dynamics.com', - bigcommerce: 'If your api domain is https://api.bigcommerce.com/stores/eubckcvkzg/v3 then store_hash is eubckcvkzg', + salesforce: 'If your Salesforce site URL is https://acme-dev.lightning.force.com, acme-dev is your domain', + sharepoint: 'If the SharePoint site URL is https://joedoe.sharepoint.com/sites/acme-dev, joedoe is the tenant and acme-dev is the site name.', + microsoftdynamicssales: 'If your Microsoft Dynamics URL is acme-dev.api.crm3.dynamics.com then acme-dev is the organization name.', + bigcommerce: 'If your api domain is https://api.bigcommerce.com/stores/joehash123/v3 then store_hash is joehash123.', }; const ProviderModal = () => { @@ -35,18 +37,16 @@ const ProviderModal = () => { const [startFlow, setStartFlow] = useState(false); const [preStartFlow, setPreStartFlow] = useState(false); const [openBasicAuthDialog,setOpenBasicAuthDialog] = useState(false); - const [openDomainDialog, setOpenDomainDialog] = useState(false); const [projectId, setProjectId] = useState(""); const [data, setData] = useState([]); const [isProjectIdReady, setIsProjectIdReady] = useState(false); const [errorResponse,setErrorResponse] = useState<{ errorPresent: boolean; errorMessage : string }>({errorPresent:false,errorMessage:''}) - const [endUserDomain, setEndUserDomain] = useState(''); const [loading, setLoading] = useState<{ status: boolean; provider: string }>({status: false, provider: ''}); - + const [additionalParams, setAdditionalParams] = useState<{[key: string]: string}>({}); const [uniqueMagicLinkId, setUniqueMagicLinkId] = useState(null); const [openSuccessDialog,setOpenSuccessDialog] = useState(false); const [currentProviderLogoURL,setCurrentProviderLogoURL] = useState('') @@ -121,9 +121,7 @@ const ProviderModal = () => { console.log('OAuth successful'); setOpenSuccessDialog(true); }, - additionalParams: { - end_user_domain: endUserDomain - } + additionalParams }); const onWindowClose = () => { @@ -196,50 +194,49 @@ const ProviderModal = () => { setLoading({status: true, provider: selectedProvider?.provider!}); setPreStartFlow(false); // Creating Basic Auth Connection - createApiKeyConnection({ - query : { - linkedUserId: magicLink?.id_linked_user as string, - projectId: projectId, - providerName: selectedProvider?.provider!, - vertical: selectedProvider?.category! + const providerMetadata = CONNECTORS_METADATA[selectedProvider.category][selectedProvider.provider]; + + if (providerMetadata.authStrategy.strategy === AuthStrategy.oauth2) { + console.log("values are "+ JSON.stringify(values)) + setAdditionalParams(values); + setStartFlow(true); + }else{ + createApiKeyConnection({ + query : { + linkedUserId: magicLink?.id_linked_user as string, + projectId: projectId, + providerName: selectedProvider?.provider!, + vertical: selectedProvider?.category! + }, + data: values }, - data: values - }, - { - onSuccess: () => { - setSelectedProvider({ - provider: '', - category: '' - }); - - setLoading({ + { + onSuccess: () => { + setSelectedProvider({ + provider: '', + category: '' + }); + + setLoading({ + status: false, + provider: '' + }); + setOpenSuccessDialog(true); + }, + onError: (error) => { + setErrorResponse({errorPresent:true,errorMessage: error.message}); + setLoading({ status: false, provider: '' - }); - setOpenSuccessDialog(true); - }, - onError: (error) => { - setErrorResponse({errorPresent:true,errorMessage: error.message}); - setLoading({ - status: false, - provider: '' - }); - setSelectedProvider({ - provider: '', - category: '' - }); - } - }); - } - - const onCloseDomainDialog = (dialogState: boolean) => { - setOpenDomainDialog(dialogState); - } - - const onDomainSubmit = () => { - setOpenDomainDialog(false); - setLoading({ status: true, provider: selectedProvider?.provider! }); - setStartFlow(true); + }); + setSelectedProvider({ + provider: '', + category: '' + }); + } + }); + } + } const filteredProviders = data.filter(provider => @@ -254,10 +251,8 @@ const ProviderModal = () => { setCurrentProvider(provider.name.toLowerCase()) const providerMetadata = CONNECTORS_METADATA[provider.vertical!.toLowerCase()][provider.name.toLowerCase()]; - if (providerMetadata.authStrategy.strategy === AuthStrategy.api_key || providerMetadata.authStrategy.strategy === AuthStrategy.basic) { + if (providerMetadata.authStrategy.strategy === AuthStrategy.api_key || providerMetadata.authStrategy.strategy === AuthStrategy.basic || (providerMetadata.authStrategy.strategy === AuthStrategy.oauth2 && providerMetadata.authStrategy.properties)) { setOpenBasicAuthDialog(true); - } else if (providerMetadata?.options?.end_user_domain) { - setOpenDomainDialog(true); } else { setLoading({ status: true, provider: provider.name.toLowerCase() }); setStartFlow(true); @@ -382,68 +377,12 @@ const ProviderModal = () => { {errors2[fieldName] &&

{errors2[fieldName]?.message}

} ))} - -

- A third-party accountant will be added. -

- - - - - - - - {/* Domain Dialog */} - - -
- -
- -
- {selectedProvider?.category && selectedProvider?.provider && CONNECTORS_METADATA[selectedProvider.category]?.[selectedProvider.provider] && ( - <> -
- {selectedProvider.provider} -
-

- Connect your {selectedProvider.provider.charAt(0).toUpperCase() + selectedProvider.provider.slice(1)} Account -

- - )} - -
{ e.preventDefault(); onDomainSubmit(); }} className="w-full space-y-4"> -
- setEndUserDomain(e.target.value)} - /> - {errors2.end_user_domain &&

{errors2.end_user_domain.message}

} -
- - {domainFormats[selectedProvider?.provider?.toLowerCase()] && ( -

- e.g., {domainFormats[selectedProvider.provider.toLowerCase()]} + {domainFormats[selectedProvider.provider] && ( +

+ {domainFormats[selectedProvider.provider]}

)} -

- A third-party accountant will be added. -

-