From 46b3215a87681bfe381fc62d1f2b985cce33da67 Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Fri, 2 Apr 2021 19:29:17 +0300 Subject: [PATCH] allow admin to update and delete events --- app/calendar/service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/calendar/service.ts b/app/calendar/service.ts index 77776cc16..39236abd4 100644 --- a/app/calendar/service.ts +++ b/app/calendar/service.ts @@ -57,7 +57,7 @@ const editEvent = async ({ const existingEvent = await prisma.calendarEvent.findFirst({ where: { AND: [{ id: eventId }, { posterId: userId }] }, }); - if (!existingEvent || userId === ADMIN_ID) { + if (!existingEvent && userId !== ADMIN_ID) { throw httpError.badRequest("no event to edit"); } @@ -81,7 +81,7 @@ const deleteEvent = async ({ const existingEvent = await prisma.calendarEvent.findFirst({ where: { AND: [{ id: eventId }, { posterId: userId }] }, }); - if (!existingEvent || userId === ADMIN_ID) { + if (!existingEvent && userId !== ADMIN_ID) { throw httpError.badRequest("no event to delete"); }