diff --git a/manager2/src/app/tps/tps.component.html b/manager2/src/app/tps/tps.component.html index 30542c1b..e1414224 100644 --- a/manager2/src/app/tps/tps.component.html +++ b/manager2/src/app/tps/tps.component.html @@ -119,7 +119,7 @@

Extend TP {{ selectedEvent ? selectedEvent.name : '' }}

diff --git a/manager2/src/app/tps/tps.component.ts b/manager2/src/app/tps/tps.component.ts index c4ddd05e..2df2ad8f 100644 --- a/manager2/src/app/tps/tps.component.ts +++ b/manager2/src/app/tps/tps.component.ts @@ -180,7 +180,7 @@ export class TpsComponent implements OnInit { this.listEvents(); } - extend_reservation(new_expire: Date) { + extend_reservation() { this.msg = ''; this.errmsg = ''; if (new Date(this.new_expire).getTime() < this.selectedEvent.end) { diff --git a/routes/tp.js b/routes/tp.js index dfa88b02..96c71759 100644 --- a/routes/tp.js +++ b/routes/tp.js @@ -299,7 +299,6 @@ router.put('/tp/:id/reserve/now', async function(req, res) { res.status(403).send({message: 'Not allowed to reserve now this reservation'}); return; } - if (reservation.to < new Date().getTime()) { res.status(403).send({message: 'End date can not be in the past'}); return; @@ -324,6 +323,10 @@ router.put('/tp/:id/reserve/extend', async function(req, res) { res.status(403).send({message: 'Not authorized'}); return; } + if(! req.body.to) { + res.status(403).send({message: 'No input'}); + return; + } if(! sansrv.sanitizeAll([req.params.id])) { res.status(403).send({message: 'Invalid parameters'}); return; @@ -351,24 +354,16 @@ router.put('/tp/:id/reserve/extend', async function(req, res) { let reservation_id = ObjectID.createFromHexString(req.params.id); - let filter = {}; - if(isadmin) { - filter = {_id: reservation_id}; - } - else{ - filter = {_id: reservation_id, owner: user.uid}; - } + let filter = {_id: reservation_id}; let reservation = await dbsrv.mongo_reservations().findOne(filter); if(!reservation){ - res.status(403).send({message: 'Not allowed to extend this reservation'}); + res.status(404).send({message: 'Reservation does not exist'}); return; } - if (req.body.to < reservation.to) { res.status(403).send({message: 'Extended end date must be after current end date'}); return; } - if (req.body.to < new Date().getTime()) { res.status(403).send({message: 'Extended end date can not be in the past'}); return;