Skip to content

Commit 8eee35a

Browse files
authored
Merge pull request #1386 from mfts/fix/doamin
fix: add plan checking to API
2 parents 2cab3c5 + ba884b4 commit 8eee35a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/team/helper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface ITeamWithDomain {
1717
teamId: string;
1818
userId: string;
1919
domain?: string;
20+
teamOptions?: {};
2021
options?: {};
2122
}
2223

@@ -97,6 +98,7 @@ export async function getTeamWithDomain({
9798
teamId,
9899
userId,
99100
domain: domainSlug,
101+
teamOptions,
100102
options,
101103
}: ITeamWithDomain) {
102104
const team = await prisma.team.findUnique({
@@ -126,6 +128,12 @@ export async function getTeamWithDomain({
126128
throw new TeamError("You are not a member of the team");
127129
}
128130

131+
// check if the team has a paid plan
132+
const teamHasPaidPlan = team?.plan !== "free";
133+
if (!teamHasPaidPlan) {
134+
throw new TeamError("Team doesn't have a paid plan");
135+
}
136+
129137
// check if the domain exists in the team
130138
let domain: Domain | undefined;
131139
if (domainSlug) {

0 commit comments

Comments
 (0)