Skip to content

Commit

Permalink
Fix permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesBochet committed Jun 22, 2023
1 parent 1b8b78d commit 703f316
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 25 deletions.
1 change: 1 addition & 0 deletions server/src/ability/ability.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class AbilityFactory {
// CommentThread
can(AbilityAction.Read, 'CommentThread', { workspaceId: workspace.id });
can(AbilityAction.Create, 'CommentThread');
can(AbilityAction.Update, 'CommentThread', { workspaceId: workspace.id });

// Comment
can(AbilityAction.Read, 'Comment', { workspaceId: workspace.id });
Expand Down
9 changes: 5 additions & 4 deletions server/src/core/company/company.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ export class CompanyResolver {
): Promise<Partial<Company>[]> {
return this.companyService.findMany({
...args,
where: {
...args.where,
AND: [accessibleBy(ability).Company],
},
where: args.where
? {
AND: [args.where, accessibleBy(ability).Company],
}
: accessibleBy(ability).Company,
select: prismaSelect.value,
});
}
Expand Down
9 changes: 5 additions & 4 deletions server/src/core/person/person.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ export class PersonResolver {
): Promise<Partial<Person>[]> {
return this.personService.findMany({
...args,
where: {
...args.where,
AND: [accessibleBy(ability).Person],
},
where: args.where
? {
AND: [args.where, accessibleBy(ability).Person],
}
: accessibleBy(ability).Person,
select: prismaSelect.value,
});
}
Expand Down
10 changes: 5 additions & 5 deletions server/src/core/pipeline/resolvers/pipeline-progress.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ export class PipelineProgressResolver {
): Promise<Partial<PipelineProgress>[]> {
return this.pipelineProgressService.findMany({
...args,
where: {
...args.where,
AND: [accessibleBy(ability).PipelineProgress],
},
select: prismaSelect.value,
where: args.where
? {
AND: [args.where, accessibleBy(ability).PipelineProgress],
}
: accessibleBy(ability).PipelineProgress,
});
}

Expand Down
9 changes: 5 additions & 4 deletions server/src/core/pipeline/resolvers/pipeline-stage.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ export class PipelineStageResolver {
): Promise<Partial<PipelineStage>[]> {
return this.pipelineStageService.findMany({
...args,
where: {
...args.where,
AND: [accessibleBy(ability).PipelineStage],
},
where: args.where
? {
AND: [args.where, accessibleBy(ability).PipelineStage],
}
: accessibleBy(ability).PipelineStage,
select: prismaSelect.value,
});
}
Expand Down
9 changes: 5 additions & 4 deletions server/src/core/pipeline/resolvers/pipeline.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ export class PipelineResolver {
): Promise<Partial<Pipeline>[]> {
return this.pipelineService.findMany({
...args,
where: {
...args.where,
AND: [accessibleBy(ability).Pipeline],
},
where: args.where
? {
AND: [args.where, accessibleBy(ability).Pipeline],
}
: accessibleBy(ability).Pipeline,
select: prismaSelect.value,
});
}
Expand Down
9 changes: 5 additions & 4 deletions server/src/core/user/user.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ export class UserResolver {
): Promise<Partial<User>[]> {
return await this.userService.findMany({
...args,
where: {
...args.where,
AND: [accessibleBy(ability).User],
},
where: args.where
? {
AND: [args.where, accessibleBy(ability).User],
}
: accessibleBy(ability).User,
select: prismaSelect.value,
});
}
Expand Down

0 comments on commit 703f316

Please sign in to comment.