allow admin to update and delete events

This commit is contained in:
Kalle (Sendou)
2021-04-02 19:29:17 +03:00
parent 732147167c
commit 46b3215a87

View File

@@ -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");
}