Skip to content
Snippets Groups Projects
Commit cf6535ec authored by elit04's avatar elit04
Browse files

more checks

parent 293a3dba
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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,
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment