diff --git a/server/src/controllers/boat.controllers.ts b/server/src/controllers/boat.controllers.ts index fd0df6819e423a56d71580b504f2f6bd1949a363..852db6c08bbbe2d706d574c364b23b91c5fe3a20 100644 --- a/server/src/controllers/boat.controllers.ts +++ b/server/src/controllers/boat.controllers.ts @@ -33,11 +33,24 @@ const createBoat = async (req: Request, res: Response) => { if (!(checkBoatName === null)) { return res - .status(404) + .status(400) .json({ success: false, error: "boatNameAlreadyExists" }); } } + //check if minP is bigger than maxP => error + if ( + !(newBoatInput.minP === undefined) && + !(newBoatInput.maxP === undefined) + ) { + if (newBoatInput.minP > newBoatInput.maxP) { + return res.status(409).json({ + success: false, + error: "maximumNumberOfSeatsMustBeBiggerOrEqualMinimalNumberOfSeats", + }); + } + } + //check if given sport-ids can be found const sportsArray = newBoatInput.sports; var check = true; diff --git a/server/src/controllers/createLogEntry.controllers.ts b/server/src/controllers/createLogEntry.controllers.ts index b16a20dd4cfa8f68f5e2158d205f94e089085267..db84351dece38ec7f70921a1fc5638deb9a613df 100644 --- a/server/src/controllers/createLogEntry.controllers.ts +++ b/server/src/controllers/createLogEntry.controllers.ts @@ -33,7 +33,7 @@ const createLogEntryController = async (req: Request, res: Response) => { if (numOfAdditionalClients !== numP - 1) { //-1 because of the responsible Person - return res.status(404).json({ + return res.status(409).json({ success: false, error: "numberOfAllGivenClientsNamesDoesNotMatchNumberOfAllClients", }); @@ -44,7 +44,7 @@ const createLogEntryController = async (req: Request, res: Response) => { const maxP = chosenBoat.maxP; if (!(logEntryInput.numP >= minP && logEntryInput.numP <= maxP)) { - return res.status(404).json({ + return res.status(409).json({ success: false, error: "numberOfAllGivenClientsDoesNotMatchRequirementsOfChosenBoatSeatNumber", @@ -58,6 +58,7 @@ const createLogEntryController = async (req: Request, res: Response) => { return res.status(201).json({ success: true, result: { + id: newLogEntry.id, startTime: newLogEntry.startTime, estimatedEndTime: newLogEntry.estimatedEndTime, email: newLogEntry.email, diff --git a/server/src/controllers/user.controllers.ts b/server/src/controllers/user.controllers.ts index cea32377fb6cab1ec1ea0f21505e0a1807d3fc82..5de45979daa688f8b291cfd55d6769c53026013e 100644 --- a/server/src/controllers/user.controllers.ts +++ b/server/src/controllers/user.controllers.ts @@ -48,6 +48,24 @@ const updateCurrentUser = async (req: Request, res: Response) => { .json({ success: true, result: {}, message: "noInputFound" }); } + if (input.first_name !== undefined && input.first_name.length >= 30) { + return res.status(400).json({ + success: false, + result: { + first_name: "Please provide maximum 30 character or empty string", + }, + }); + } + + if (input.last_name !== undefined && input.last_name.length >= 30) { + return res.status(400).json({ + success: false, + result: { + last_name: "Please provide maximum 30 character or empty string", + }, + }); + } + if (input.password !== undefined) { input.password = await bcrypt.hash(input.password, 10); }