(projectId: string, ctx: TRPCContext)
| 69 | }; |
| 70 | |
| 71 | export const requireCanModifyProject = async (projectId: string, ctx: TRPCContext) => { |
| 72 | ctx.markAccessControlRun(); |
| 73 | |
| 74 | const userId = requireUserId(ctx); |
| 75 | |
| 76 | const canModify = await prisma.projectUser.findFirst({ |
| 77 | where: { |
| 78 | userId, |
| 79 | projectId, |
| 80 | role: { in: [ProjectUserRole.OWNER, ProjectUserRole.ADMIN, ProjectUserRole.MEMBER] }, |
| 81 | }, |
| 82 | }); |
| 83 | |
| 84 | if (!canModify) { |
| 85 | throw new TRPCError({ |
| 86 | code: "UNAUTHORIZED", |
| 87 | message: "Only project members can perform this action.", |
| 88 | }); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | export const requireIsProjectAdmin = async (projectId: string, ctx: TRPCContext) => { |
| 93 | ctx.markAccessControlRun(); |
no test coverage detected