diff --git a/apps/web/pages/api/v1/environments/[environmentId]/posthog/export/index.ts b/apps/web/pages/api/v1/environments/[environmentId]/posthog/export/index.ts index a159730578..37cb4af8ae 100644 --- a/apps/web/pages/api/v1/environments/[environmentId]/posthog/export/index.ts +++ b/apps/web/pages/api/v1/environments/[environmentId]/posthog/export/index.ts @@ -1,18 +1,12 @@ -import { getSessionOrUser, hasEnvironmentAccess } from "@/lib/api/apiHelper"; +import { hasEnvironmentAccess } from "@/lib/api/apiHelper"; import { prisma } from "@formbricks/database"; import type { NextApiRequest, NextApiResponse } from "next"; export default async function handle(req: NextApiRequest, res: NextApiResponse) { - // Check Authentication - const user: any = await getSessionOrUser(req, res); - if (!user) { - return res.status(401).json({ message: "Not authenticated" }); - } - const environmentId = req.query?.environmentId?.toString(); - const hasAccess = await hasEnvironmentAccess(user, environmentId); - if (hasAccess === false) { + const hasAccess = await hasEnvironmentAccess(req, res, environmentId); + if (!hasAccess) { return res.status(403).json({ message: "Not authorized" }); } diff --git a/apps/web/pages/api/v1/environments/[environmentId]/posthog/import/index.ts b/apps/web/pages/api/v1/environments/[environmentId]/posthog/import/index.ts index e9dceaaf51..1cffd0e21a 100644 --- a/apps/web/pages/api/v1/environments/[environmentId]/posthog/import/index.ts +++ b/apps/web/pages/api/v1/environments/[environmentId]/posthog/import/index.ts @@ -1,4 +1,4 @@ -import { getSessionOrUser, hasEnvironmentAccess } from "@/lib/api/apiHelper"; +import { hasEnvironmentAccess } from "@/lib/api/apiHelper"; import { prisma } from "@formbricks/database"; import type { NextApiRequest, NextApiResponse } from "next"; @@ -8,20 +8,14 @@ interface FormbricksUser { } export default async function handle(req: NextApiRequest, res: NextApiResponse) { - // Check Authentication - const user: any = await getSessionOrUser(req, res); - if (!user) { - return res.status(401).json({ message: "Not authenticated" }); - } - const environmentId = req.query?.environmentId?.toString(); if (!environmentId) { return res.status(400).json({ message: "Missing environmentId" }); } - const hasAccess = await hasEnvironmentAccess(user, environmentId); - if (hasAccess === false) { + const hasAccess = await hasEnvironmentAccess(req, res, environmentId); + if (!hasAccess) { return res.status(403).json({ message: "Not authorized" }); } diff --git a/packages/database/.env b/packages/database/.env deleted file mode 120000 index c7360fb82d..0000000000 --- a/packages/database/.env +++ /dev/null @@ -1 +0,0 @@ -../../.env \ No newline at end of file diff --git a/packages/database/.env b/packages/database/.env new file mode 100644 index 0000000000..c7360fb82d --- /dev/null +++ b/packages/database/.env @@ -0,0 +1 @@ +../../.env \ No newline at end of file