no need to use faulty regex in booker finding

This commit is contained in:
Thomas Ruoff
2020-08-22 00:09:25 +02:00
parent e9f4753fdc
commit ebdcd5cd24

View File

@@ -38,6 +38,13 @@ export async function getBookedDays() {
.sort()
}
export async function getBookingByUUID(uuid) {
await connect()
const booking = await Booking.findOne({ uuid })
await booking.populate('booker').execPopulate()
return booking
}
export async function createBooking({
startDate,
endDate,
@@ -58,8 +65,7 @@ export async function createBooking({
throw new mongoose.Error.ValidationError(booking)
}
const ignoreCaseEmailMatcher = new RegExp(email, 'i')
let booker = await Booker.findOne({ email: ignoreCaseEmailMatcher }).exec()
let booker = await Booker.findOne({ email }).exec()
if (!booker) {
booker = new Booker({ name, email, street, zip, city })
await booker.save()