Skip to content

Commit

Permalink
Update hasAccess to hasReadAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Sep 11, 2024
1 parent 72371f2 commit 385bd76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/errors/subworkflow-policy-denial.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Options = {
subworkflowProject: Project;

/** Whether the user has access to the subworkflow via project and scope. */
hasAccess: boolean;
hasReadAccess: boolean;

/** URL of the n8n instance. */
instanceUrl: string;
Expand All @@ -30,7 +30,7 @@ export class SubworkflowPolicyDenialError extends WorkflowOperationError {
subworkflowId,
subworkflowProject,
instanceUrl,
hasAccess,
hasReadAccess,
ownerName,
node,
}: Options) {
Expand All @@ -51,7 +51,7 @@ export class SubworkflowPolicyDenialError extends WorkflowOperationError {
};

const description = () => {
if (hasAccess) return descriptions.accessible;
if (hasReadAccess) return descriptions.accessible;
if (subworkflowProject.type === 'personal') return descriptions.inaccessiblePersonalProject;
if (subworkflowProject.type === 'team') return descriptions.inaccesibleTeamProject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ export class SubworkflowPolicyChecker {
}

private async errorDetails(subworkflowProject: Project, subworkflow: Workflow, userId?: string) {
const hasAccess = userId
const hasReadAccess = userId
? await this.accessService.hasReadAccess(userId, subworkflow.id)
: false; /* no user ID in policy check for error workflow, so `false` to keep error message generic */

if (subworkflowProject.type === 'team') return { hasAccess };
if (subworkflowProject.type === 'team') return { hasReadAccess };

const owner = await this.ownershipService.getPersonalProjectOwnerCached(subworkflowProject.id);

assert(owner !== null); // only `null` if not personal

return {
hasAccess,
hasReadAccess,
ownerName: owner.firstName + ' ' + owner.lastName,
};
}
Expand Down

0 comments on commit 385bd76

Please sign in to comment.