make isAdminSession usable by api routes

This commit is contained in:
Thomas Ruoff
2020-11-04 00:33:35 +01:00
parent 1dfd1f1f8b
commit 7ee9803adc
5 changed files with 19 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import withSession, { isAdminSession } from '../../../../../lib/session'
export default withSession(async function billHandler(req, res) {
if (!isAdminSession(req, res)) {
res.status(403).send({ message: 'Not Authorized' })
return
}

View File

@@ -9,6 +9,7 @@ import { BOOKING_STATUS } from '../../../../../db/enums'
export default withSession(async function bookingHandler(req, res) {
if (!isAdminSession(req, res)) {
res.status(403).send({ message: 'Not Authorized' })
return
}
@@ -42,8 +43,10 @@ export default withSession(async function bookingHandler(req, res) {
if (booking.status === BOOKING_STATUS.CONFIRMED) {
sendBookingConfirmed(booking)
console.log(`Booking ${booking.uuid} confirm sent`)
} else if (booking.status === BOOKING_STATUS.REJECTED) {
sendBookingRejected(booking)
console.log(`Booking ${booking.uuid} rejected sent`)
}
break