Skip to content

Commit

Permalink
Block delete reservation after its start time
Browse files Browse the repository at this point in the history
If start time of equipment or place passed current time, then block delete function
  • Loading branch information
khkim6040 committed Jan 19, 2024
1 parent fd492fd commit 629cd54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/popo/reservation/equip/reserve.equip.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BadRequestException,
Body,
Controller,
Delete,
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 4 additions & 0 deletions src/popo/reservation/place/reserve.place.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BadRequestException,
Body,
Controller,
Delete,
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 629cd54

Please sign in to comment.