在尝试使用护照本地猫鼬注册时遇到问题。
当我提交注册表时,此错误记录:
用户:
var mongoose = require('mongoose'),
passportLocalMongoose = require('passport-local-mongoose');
var UserSchema = new mongoose.Schema({
username: String,
password: String,
email: String
});
UserSchema.plugin(passportLocalMongoose);
module.exports = mongoose.model("User", UserSchema);
用户控制器:
var db = require('../vendor/db'),
passport = require('passport'),
User = require('../model/user');
module.exports = {
register: function(req, res){
User.register(new User({email: req.body.email, username: req.body.username}, req.body.password, function (err, user) {
if(err){
console.log(err);
return res.render('user/register.twig');
}
passport.authenticate("local")(req, res, function(){
res.redirect("/home");
});
}));
},
isLoggedIn: function (req, res, next) {
if (req.isAuthenticated())
return next();
res.redirect('/');
}
};
怎么了?
答案 0 :(得分:1)
我遇到了同样的错误,我在新用户()
中错过了一个“)”应该是这样的:
new User({email: req.body.email, username: req.body.username}),req.body.password, function (err, user) {...