From 2ada162c9045e032062461e429e8bafa8ddd483f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Thu, 30 Dec 2021 09:40:09 -0700 Subject: [PATCH] Update eventType.ts --- pages/api/eventType.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/api/eventType.ts b/pages/api/eventType.ts index 3f7e375079..730abecde0 100644 --- a/pages/api/eventType.ts +++ b/pages/api/eventType.ts @@ -7,7 +7,7 @@ import prisma from "@lib/prisma"; export default async function handler(req: NextApiRequest, res: NextApiResponse) { const session = await getSession({ req: req }); - if (!session) { + if (!session?.user?.id) { res.status(401).json({ message: "Not authenticated" }); return; } @@ -34,7 +34,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const user = await prisma.user.findUnique({ where: { - id: session?.user?.id, + id: session.user.id, }, select: { id: true, @@ -83,7 +83,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) // backwards compatibility, TMP: const typesRaw = await prisma.eventType.findMany({ where: { - userId: session?.user?.id, + userId: session.user.id, }, select: eventTypeSelect, });