Skip to content

Scheduling infrastructure for absolutely everyone.

fix: to allow paypal install on team when user already installed (#16553)

Vijayc056cabbbd83
diff --git a/packages/app-store/paypal/api/add.ts b/packages/app-store/paypal/api/add.ts
index bab1b9390c0..e2762565d0f 100644
--- a/packages/app-store/paypal/api/add.ts
+++ b/packages/app-store/paypal/api/add.ts
@@ -1,5 +1,6 @@
import type { NextApiRequest, NextApiResponse } from "next";
+import { throwIfNotHaveAdminAccessToTeam } from "@calcom/app-store/_utils/throwIfNotHaveAdminAccessToTeam";
import prisma from "@calcom/prisma";
import config from "../config.json";
@@ -8,12 +9,18 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (!req.session?.user?.id) {
return res.status(401).json({ message: "You must be logged in to do this" });
}
+
+ const { teamId } = req.query;
+
+ await throwIfNotHaveAdminAccessToTeam({ teamId: Number(teamId) ?? null, userId: req.session.user.id });
+ const installForObject = teamId ? { teamId: Number(teamId) } : { userId: req.session.user.id };
+
const appType = config.type;
try {
const alreadyInstalled = await prisma.credential.findFirst({
where: {
type: appType,
- userId: req.session.user.id,
+ ...installForObject,
},
});
if (alreadyInstalled) {