Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: add plan checking to API

Marc Seitzba884b44ea57
diff --git a/lib/team/helper.ts b/lib/team/helper.ts
index f1ede0fb..69fbec22 100644
--- a/lib/team/helper.ts
+++ b/lib/team/helper.ts
@@ -17,6 +17,7 @@ interface ITeamWithDomain {
teamId: string;
userId: string;
domain?: string;
+ teamOptions?: {};
options?: {};
}
@@ -97,6 +98,7 @@ export async function getTeamWithDomain({
teamId,
userId,
domain: domainSlug,
+ teamOptions,
options,
}: ITeamWithDomain) {
const team = await prisma.team.findUnique({
@@ -126,6 +128,12 @@ export async function getTeamWithDomain({
throw new TeamError("You are not a member of the team");
}
+ // check if the team has a paid plan
+ const teamHasPaidPlan = team?.plan !== "free";
+ if (!teamHasPaidPlan) {
+ throw new TeamError("Team doesn't have a paid plan");
+ }
+
// check if the domain exists in the team
let domain: Domain | undefined;
if (domainSlug) {