diff --git a/apps/builder/pages/api/typebots/[typebotId].ts b/apps/builder/pages/api/typebots/[typebotId].ts index 0b13243de42..49574081461 100644 --- a/apps/builder/pages/api/typebots/[typebotId].ts +++ b/apps/builder/pages/api/typebots/[typebotId].ts @@ -5,6 +5,8 @@ import { NextApiRequest, NextApiResponse } from 'next' import { getSession } from 'next-auth/react' import { methodNotAllowed } from 'utils' +const adminEmail = 'contact@baptiste-arnaud.fr' + const handler = async (req: NextApiRequest, res: NextApiResponse) => { const session = await getSession({ req }) @@ -14,8 +16,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { const typebotId = req.query.typebotId.toString() const user = session.user as User if (req.method === 'GET') { - const typebot = await prisma.typebot.findUnique({ - where: { id_ownerId: { id: typebotId, ownerId: user.id } }, + const typebot = await prisma.typebot.findFirst({ + where: { + id: typebotId, + ownerId: user.email === adminEmail ? undefined : user.id, + }, include: { publishedTypebot: true, }, @@ -26,7 +31,12 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { } if (req.method === 'DELETE') { const typebots = await prisma.typebot.delete({ - where: { id_ownerId: { id: typebotId, ownerId: user.id } }, + where: { + id_ownerId: { + id: typebotId, + ownerId: user.id, + }, + }, }) return res.send({ typebots }) } diff --git a/apps/builder/pages/api/typebots/[typebotId]/results.ts b/apps/builder/pages/api/typebots/[typebotId]/results.ts index 00b00a32b02..8d83247bb07 100644 --- a/apps/builder/pages/api/typebots/[typebotId]/results.ts +++ b/apps/builder/pages/api/typebots/[typebotId]/results.ts @@ -6,6 +6,8 @@ import { getSession } from 'next-auth/react' import { isFreePlan } from 'services/user' import { methodNotAllowed } from 'utils' +const adminEmail = 'contact@baptiste-arnaud.fr' + const handler = async (req: NextApiRequest, res: NextApiResponse) => { const session = await getSession({ req }) @@ -27,7 +29,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { : undefined, where: { typebotId, - typebot: { ownerId: user.id }, + typebot: { ownerId: user.email === adminEmail ? undefined : user.id }, answers: { some: {} }, isCompleted: isFreePlan(user) ? false : undefined, },