最近、同様の質問がありましたが、まだ取得できません。新しいユーザーを追加する前に、登録ページを検証する必要があります。
app.post('/signup', function(req, res) {
//checking if first name is filled
if (req.body.first_name = "" || req.body.first_name = null || req.body.first_name = undefined) {
res.render('signup', { "title": "Ttitle", "menu": "signup", user: req.user, "error" : "empty_first_name" });
break;
}
//checking if last name is filled
if (req.body.last_name = "" || req.body.last_name = null || req.body.last_name = undefined) {
res.render('signup', { "title": "Ttitle", "menu": "signup", user: req.user, "error" : "empty_last_name" });
break;
}
//checking if email is filled
if (req.body.email = "" || req.body.email = null || req.body.email = undefined) {
res.render('signup', { "title": "Ttitle", "menu": "signup", user: req.user, "error" : "empty_email" });
break;
}
//checking if passwords match
if (req.body.password != req.body.repassword) {
res.render('signup', { "title": "Ttitle", "menu": "signup", user: req.user, "error" : "pass_missmatch" });
break;
}
...
...
...
//and finally if everything seems to be OK...
addUser(req.body.email, req.body.password, req.body.first_name, req.body.last_name, req.body.country, function(status) {
res.render('signup', { "title": "Ttitle", "menu": "signup", user: req.user, "success" : 1 });
});
});
Node.JS は、すべての中断が違法であることを教えてくれます。しかし、適切な方法で機能を壊すにはどうすればよいでしょうか? 何も返しません。ありがとう!