Browse Source

new user and new travel check if empty fields

master
idoctnef 8 years ago
parent
commit
cfa84bfa6d
2 changed files with 39 additions and 1 deletions
  1. +22
    -0
      controllers/travelController.js
  2. +17
    -1
      controllers/userController.js

+ 22
- 0
controllers/travelController.js

@ -69,6 +69,28 @@ exports.addTravel = function(req, res) {
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);

+ 17
- 1
controllers/userController.js

@ -79,7 +79,23 @@ exports.addUser = function(req, res) {
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);

Loading…
Cancel
Save