arnaucube
arnaucube/commonroutesServerPublic Self-hosted repository
new user and new travel check if empty fields
idoctnef idoctnef@openmailbox.org
Mon, 10 Oct 2016 19:35:47 +0200
commit

cfa84bfa6d168b8460d8bd15068148dd07a59dd6

parent

0fb507c48501e40b63da99ba73d54677e922434d

2 files changed, 39 insertions(+), 1 deletions(-)

jump to
M controllers/travelController.js → controllers/travelController.js

@@ -69,6 +69,28 @@ telegram: req.body.telegram,

collectivized: req.body.collectivized, modality: req.body.modality }); + if(travel.title==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(travel.description==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(travel.from==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(travel.to==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(travel.date==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(travel.seats==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(travel.title==undefined) + { + return res.status(500).jsonp("empty inputs"); + } travel.save(function(err, travel) { if(err) return res.send(500, err.message);
M controllers/userController.js → controllers/userController.js

@@ -79,7 +79,23 @@ mail: req.body.mail,

phone: req.body.phone, telegram: req.body.telegram }); - + if(user.username==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(user.password==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(user.description==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(user.avatar==undefined) + { + return res.status(500).jsonp("empty inputs"); + }else if(user.mail==undefined) + { + return res.status(500).jsonp("empty inputs"); + } + user.save(function(err, user) { if(err) return res.send(500, err.message); res.status(200).jsonp(user);