我正在为 Node.JS 使用 Sails.JS 框架。我编写了一个 config/middleware.js,它有一个验证处理程序并建立了初始连接。该页面当前在 config/routes.js 推送的 AuthController 上出错。
控制台日志:
Fired Facebook error: Error: no strategy registered under name: facebook at attempt (/project/node_modules/passport/lib/passport/middleware/authenticate.js:237:37) at Passport.authenticate (/project/node_modules/passport/lib/passport/middleware/authenticate.js:244:7) at AuthController.facebook (/project/api/controllers/AuthController.js:35:4)
Authcontroller.js 函数
'facebook': function(req, res, next) {
console.log("Fired Facebook");
passport.authenticate('facebook', {
failureRedirect: '/auth',
scope: 'email'
}, function(err, user) {
console.log("Fired Login Attempt");
req.logIn(user, function(err) {
if (err) {
console.log(err);
res.view('500');
return;
}
res.redirect('home/index');
return;
});
})(req, res, next);
Passport-facebook 和 passport 都在节点模块中。
包.json
"dependencies": {
"sails": "0.9.4",
"grunt": "0.4.1",
"sails-disk": "~0.9.0",
"ejs": "0.8.4",
"optimist": "0.3.4",
"passport": "latest",
"passport-local": "latest",
"passport-facebook":"latest",
"sails-mongo":"latest",
"bcrypt": "0.7.6"
},