fix: bookings:id fix bad isAdmin double if adding missing return replace with || OR instead

This commit is contained in:
Agusti Fernandez Pardo
2022-07-08 18:49:55 +02:00
parent c28e96045c
commit 54b36b9624
+3 -4
View File
@@ -23,10 +23,9 @@ export async function bookingById(
});
if (!userWithBookings) throw new Error("User not found");
const userBookingIds = userWithBookings.bookings.map((booking: { id: number }) => booking.id).flat();
if (!isAdmin) {
if (!userBookingIds.includes(safeQuery.data.id)) res.status(401).json({ message: "Unauthorized" });
} else {
if (!isAdmin || !userBookingIds.includes(safeQuery.data.id))
res.status(401).json({ message: "Unauthorized" });
else {
switch (method) {
/**
* @swagger