Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sync): verifyOwnership not awaited #1952

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/server/lib/controllers/sync.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
SyncClient,
updateScheduleStatus,
updateSuccess as updateSuccessActivityLog,
createActivityLogAndLogMessage,
createActivityLogMessageAndEnd,
createActivityLog,
getAndReconcileDifferences,
Expand Down Expand Up @@ -44,7 +43,8 @@ import {
getEnvironmentAndAccountId,
getSyncAndActionConfigsBySyncNameAndConfigId,
isOk,
isErr
isErr,
createActivityLogMessage
} from '@nangohq/shared';

class SyncController {
Expand Down Expand Up @@ -614,20 +614,21 @@ class SyncController {
environment_id: environment.id,
operation_name: sync_name
};
const activityLogId = await createActivityLog(log);

if (!verifyOwnership(nango_connection_id, environment.id, sync_id)) {
await createActivityLogAndLogMessage(log, {
if (!(await verifyOwnership(nango_connection_id, environment.id, sync_id))) {
await createActivityLogMessage({
level: 'error',
activity_log_id: activityLogId!,
environment_id: environment.id,
timestamp: Date.now(),
content: `Unauthorized access to run the command: "${action}" for sync: ${sync_id}`
});

res.sendStatus(401);
return;
}

const activityLogId = await createActivityLog(log);

const syncClient = await SyncClient.getInstance();

if (!syncClient) {
Expand Down
Loading