Account.register(new Account({ username : req.body.username }), req.body.password, function(err, account) { if (err) { return res.render("register", {info: "Sorry. That username already exists. Try again."}); } passport.authenticate('local')(req, res, function () { req.session.save(function (err) { if (err) { return next(err); } res.redirect('/'); }); }); });
送出表單時,一定要有在表單裡設定 req.body.username req.body.password 不然會Bad Request
不知道mongoose在那裡有作驗證
https://github.com/mjhea0/passport-local-express4
沒有留言:
張貼留言