(projectId: string, ctx: TRPCContext)
| 90 | }; |
| 91 | |
| 92 | export const requireIsProjectAdmin = async (projectId: string, ctx: TRPCContext) => { |
| 93 | ctx.markAccessControlRun(); |
| 94 | |
| 95 | const userId = requireUserId(ctx); |
| 96 | |
| 97 | const isAdmin = await prisma.projectUser.findFirst({ |
| 98 | where: { |
| 99 | userId, |
| 100 | projectId, |
| 101 | role: { in: [ProjectUserRole.OWNER, ProjectUserRole.ADMIN] }, |
| 102 | }, |
| 103 | }); |
| 104 | |
| 105 | if (!isAdmin) { |
| 106 | throw new TRPCError({ |
| 107 | code: "UNAUTHORIZED", |
| 108 | message: "Only project admins can perform this action.", |
| 109 | }); |
| 110 | } |
| 111 | }; |
| 112 | |
| 113 | export const requireIsAdmin = async (ctx: TRPCContext) => { |
| 114 | ctx.markAccessControlRun(); |
no test coverage detected