2
我爲Node.JS使用了Sails.JS框架。我寫了一個config/middleware.js,它有一個驗證處理程序並進行初始連接。該頁面當前正在由config/routes.js推送的AuthController上出錯。使用Sails.JS框架的Node.JS - 護照:沒有名稱下注冊的策略:facebook
控制檯日誌:
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和護照都在節點的模塊。解決
的package.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"
},
哪些?有同樣的問題。 – Ric