MCPcopy Index your code
hub / github.com/OpenPipe/OpenPipe / requireCanModifyProject

Function requireCanModifyProject

app/src/utils/accessControl.ts:71–90  ·  view source on GitHub ↗
(projectId: string, ctx: TRPCContext)

Source from the content-addressed store, hash-verified

69};
70
71export 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
92export const requireIsProjectAdmin = async (projectId: string, ctx: TRPCContext) => {
93 ctx.markAccessControlRun();

Callers 9

monitors.router.tsFile · 0.90
projects.router.tsFile · 0.90
archives.router.tsFile · 0.90
datasets.router.tsFile · 0.90
createFineTune.tsFile · 0.90

Calls 1

requireUserIdFunction · 0.85

Tested by

no test coverage detected