From 629cd54f90874d57cd31f128643a81affd4d8888 Mon Sep 17 00:00:00 2001 From: Gwanho Kim Date: Fri, 19 Jan 2024 21:06:11 +0900 Subject: [PATCH] Block delete reservation after its start time If start time of equipment or place passed current time, then block delete function --- src/popo/reservation/equip/reserve.equip.controller.ts | 4 ++++ src/popo/reservation/place/reserve.place.controller.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/popo/reservation/equip/reserve.equip.controller.ts b/src/popo/reservation/equip/reserve.equip.controller.ts index 07a991a..0c54012 100644 --- a/src/popo/reservation/equip/reserve.equip.controller.ts +++ b/src/popo/reservation/equip/reserve.equip.controller.ts @@ -1,4 +1,5 @@ import { + BadRequestException, Body, Controller, Delete, @@ -169,6 +170,9 @@ export class ReserveEquipController { await this.reserveEquipService.remove(uuid); } else { if (reservation.booker_id == user.uuid) { + if(reservation.start_time < new Date().toISOString()) { + throw new BadRequestException('Cannot delete past reservation'); + } await this.reserveEquipService.remove(uuid); } else { throw new UnauthorizedException('Unauthorized delete action'); diff --git a/src/popo/reservation/place/reserve.place.controller.ts b/src/popo/reservation/place/reserve.place.controller.ts index cc43f5a..4a3354d 100644 --- a/src/popo/reservation/place/reserve.place.controller.ts +++ b/src/popo/reservation/place/reserve.place.controller.ts @@ -1,4 +1,5 @@ import { + BadRequestException, Body, Controller, Delete, @@ -285,6 +286,9 @@ export class ReservePlaceController { await this.reservePlaceService.remove(uuid); } else { if (reservation.booker_id == user.uuid) { + if(reservation.start_time < new Date().toISOString()) { + throw new BadRequestException('Cannot delete past reservation'); + } await this.reservePlaceService.remove(uuid); } else { throw new UnauthorizedException('Unauthorized delete action');