Skip to content

Commit

Permalink
feat: save and forward all query parameters during oauth connection (#15
Browse files Browse the repository at this point in the history
)
  • Loading branch information
paulkr authored May 31, 2024
1 parent 0006941 commit 1689f71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { generateEmbedTokensRecord } from '@libs-private/service-logic/generator
import { generateId } from '@integrationos/rust-utils';

const GET_EVENT_ACCESS_RECORD_URL = process.env.CONNECTIONS_API_BASE_URL + 'v1/event-access';
const CREATE_CONNECTION_URL = process.env.CONNECTIONS_API_BASE_URL + 'v1/connections';
const CREATE_CONNECTION_URL = process.env.CONNECTIONS_API_BASE_URL + 'v1/connections';
const CREATE_OAUTH_CONNECTION_URL = process.env.CONNECTIONS_API_BASE_URL + 'v1/oauth';
const LIST_CONNECTION_DEFINITIONS_URL = process.env.CONNECTIONS_API_BASE_URL + 'v1/public/connection-definitions';

Expand Down Expand Up @@ -137,10 +137,10 @@ export const useEventLinksService = (ctx: Context, ownership: Ownership) => {
authFormData,
group: authFormData['NAME']
? `${_.replace(
authFormData['NAME'],
/[^a-zA-Z0-9_]/g,
'-'
).toLowerCase()}-${uuidv4().replace(/-/g, '').substring(0, 10)}`
authFormData['NAME'],
/[^a-zA-Z0-9_]/g,
'-'
).toLowerCase()}-${uuidv4().replace(/-/g, '').substring(0, 10)}`
: link?.group,
},
});
Expand Down Expand Up @@ -173,6 +173,7 @@ export const useEventLinksService = (ctx: Context, ownership: Ownership) => {
redirectUri,
type,
formData,
additionalData,
}: CreateOauthEmbedConnectionPayload): Promise<
BResult<ConnectionRecord, 'service', unknown>
> {
Expand Down Expand Up @@ -209,7 +210,6 @@ export const useEventLinksService = (ctx: Context, ownership: Ownership) => {
const contextMetadata = ctx.meta as any;
const headers = contextMetadata.request.headers;


try {
const { listAccessKeys } = useEventAccessService(ctx, link.ownership);
const eventAccessRecords = await listAccessKeys({
Expand Down Expand Up @@ -239,22 +239,23 @@ export const useEventLinksService = (ctx: Context, ownership: Ownership) => {
},
data: {
__isEngineeringAccount__:
link?.usageSource === 'user-dashboard' ? true : false,
link?.usageSource === 'user-dashboard' ? true : false,
clientId,
payload: {
code,
redirectUri,
formData,
additionalData
},
type,
connectionDefinitionId,
label: formData?.['NAME'] ?? link?.label,
group: formData?.['NAME']
? `${_.replace(
formData?.['NAME'] as string,
/[^a-zA-Z0-9_]/g,
'-'
).toLowerCase()}-${uuidv4().replace(/-/g, '').substring(0, 10)}`
formData?.['NAME'] as string,
/[^a-zA-Z0-9_]/g,
'-'
).toLowerCase()}-${uuidv4().replace(/-/g, '').substring(0, 10)}`
: link?.group,
},
});
Expand Down Expand Up @@ -291,7 +292,7 @@ export const useEventLinksService = (ctx: Context, ownership: Ownership) => {
const settings = settingsResult.unwrap();

// Get the event access records
const eventAccessRecords = await makeHttpNetworkCall<EventAccessRecords>({
const eventAccessRecords = await makeHttpNetworkCall<EventAccessRecords>({
url: GET_EVENT_ACCESS_RECORD_URL,
method: 'GET',
headers: {
Expand Down
1 change: 1 addition & 0 deletions packages/types/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ export interface CreateOauthEmbedConnectionPayload {
redirectUri: string;
clientId: string;
formData?: { [K: string]: unknown };
additionalData?: { [K: string]: unknown };
}

0 comments on commit 1689f71

Please sign in to comment.