Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix(dataroom): allow members and scoped members to delete dataroom folders
Marc Seitz29792286d7a2
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/folders/manage/[folderId]/index.ts b/pages/api/teams/[teamId]/datarooms/[id]/folders/manage/[folderId]/index.tsindex 440805ab..c07b7c8b 100644--- a/pages/api/teams/[teamId]/datarooms/[id]/folders/manage/[folderId]/index.ts+++ b/pages/api/teams/[teamId]/datarooms/[id]/folders/manage/[folderId]/index.ts@@ -3,6 +3,7 @@ import { NextApiRequest, NextApiResponse } from "next";import { authOptions } from "@/pages/api/auth/[...nextauth]";import { getServerSession } from "next-auth/next";+import { enforceDataroomMemberScope } from "@/lib/api/rbac/guard";import { errorhandler } from "@/lib/errorHandler";import prisma from "@/lib/prisma";import { CustomUser } from "@/lib/types";@@ -30,6 +31,13 @@ export default async function handle(const userId = (session.user as CustomUser).id;+ // Scoped members may only manage folders within their assigned rooms.+ if (+ await enforceDataroomMemberScope({ userId, teamId, dataroomId, res })+ ) {+ return;+ }+try {const teamAccess = await prisma.userTeam.findUnique({where: {@@ -47,13 +55,6 @@ export default async function handle(return res.status(401).json({ message: "Unauthorized" });}- if (teamAccess.role !== "ADMIN" && teamAccess.role !== "MANAGER") {- return res.status(403).json({- message:- "You are not permitted to perform this action. Only admin and managers can delete dataroom folders.",- });- }-const dataroom = await prisma.dataroom.findUnique({where: {id: dataroomId,