Mongoose 経由でアカウントを作成した後、ユーザーをログインしようとすると、未定義の関数エラーが発生します...
TypeError: undefined is not a function
at /node_modules/passport/lib/passport/http/request.js:44:48
at pass (/node_modules/passport/lib/passport/index.js:240:14)
at Passport.serializeUser (/node_modules/passport/lib/passport/index.js:242:5)
at IncomingMessage.req.login.req.logIn (/node_modules/passport/lib/passport/http/request.js:43:29)
at Promise.<anonymous> (/routes/index.js:33:25)
at Promise.addBack (/node_modules/mongoose/lib/promise.js:120:8)
routes/index.js の登録関数は次のようになります。
exports.register = function (req, res) {
// Generate salt
Common.bcrypt.genSalt(function(err, salt) {
req.body.salt = salt;
// Generate hash
Common.bcrypt.hash(req.body.password, salt, function(error, hash) {
req.body.hash = hash;
// Remove clear text password
delete req.body.password;
// Save new user
new Model.User(req.body).save(function(err, user) {
console.log(err);
console.log(req);
if (user) {
req.login(user);
req.redirect('/');
} else {
res.json(false);
}
});
});
});
何か案は?