こんにちは私はNodeJsで新しく、このチュートリアルhttp://code.tutsplus.com/tutorials/authenticating-nodejs-applications-with-passport--cms-21619に従って認証してアプリケーションを作成しています。 これは私のindex.jsルートファイルpassport.authenticateは関数ではありません
あるTypeError: passport.authenticate is not a function at module.exports (C:\myApp\routes\index.js:24:34)
私はチュートリアルからすべてのstructreとコードに従うことを試してみました(コードはgithubのhttps://github.com/tutsplus/passport-mongoである)が、私は、ブラウザ に私のアプリを開いたとき、私は、このエラーのエラーを取得
var express = require('express');
var router = express.Router();
var passport = require('passport');
var isAuthenticated = function (req, res, next) {
// if user is authenticated in the session, call the next() to call the next request handler
// Passport adds this method to request object. A middleware is allowed to add properties to
// request and response objects
if (req.isAuthenticated())
return next();
// if the user is not authenticated then redirect him to the login page
res.redirect('/');
}
module.exports = function(passport){
/* GET login page. */
router.get('/', function(req, res) {
// Display the Login page with any flash message, if any
res.render('index', { message: req.flash('message') });
});
/* Handle Login POST */
router.post('/login', passport.authenticate('login', {
successRedirect: '/home',
failureRedirect: '/',
failureFlash : true
}));
/* GET Registration Page */
router.get('/signup', function(req, res){
res.render('register',{message: req.flash('message')});
});
/* Handle Registration POST */
router.post('/signup', passport.authenticate('signup', {
successRedirect: '/home',
failureRedirect: '/signup',
failureFlash : true
}));
/* GET Home Page */
router.get('/home', isAuthenticated, function(req, res){
res.render('home', { user: req.user });
});
/* Handle Logout */
router.get('/signout', function(req, res) {
req.logout();
res.redirect('/');
});
return router;
}
Probabbly問題があり、多分ルーティングは特急の一部のバージョンの変化でしたが、私は問題が何であるかを把握傾けます。 お願いします。