Skip to content

Commit

Permalink
Fix issue with workflow process to initialize db connection correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
krynble committed Mar 7, 2022
1 parent ea40412 commit 4d4b663
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/cli/src/UserManagement/UserManagementHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ export async function checkPermissionsForExecution(
workflow: Workflow,
userId: string,
): Promise<boolean> {
const user = await getUserById(userId);
if (user.globalRole.name === 'owner') {
return true;
}

const credentialIds = new Set();
const nodeNames = Object.keys(workflow.nodes);
// Iterate over all nodes
Expand Down Expand Up @@ -161,6 +156,13 @@ export async function checkPermissionsForExecution(
// If the workflow does not use any credentials, then we're fine
return true;
}
// If this check happens on top, we may get
// unitialized db errors.
// Db is certainly initialized if workflow uses credentials.
const user = await getUserById(userId);
if (user.globalRole.name === 'owner') {
return true;
}

// Check for the user's permission to all used credentials
const credentialCount = await Db.collections.SharedCredentials!.count({
Expand Down

0 comments on commit 4d4b663

Please sign in to comment.