Когда я использую passprot. js выдает эту ошибку Неизвестная стратегия аутентификации "local" !
config / configuration. js
var passport = require('passport')
, LocalStrategy = require('passport-local').Strategy;
var User = require('../model/students');
passport.use('local', new LocalStrategy(
function(username, password, done) {
User.findOne({ username: email }, function(err, user) {
if (err) { return done(err); }
if (!user) {
return done(null, false, { message: 'Incorrect username.' });
}
if (!user.validPassword(password)) {
return done(null, false, { message: 'Incorrect password.' });
}
return done(null, user);
});
}
));
index. js
router.get('/test', function (req, res, next) {
res.render('test');
});
router.post('/test',
passport.authenticate('local', { successRedirect: '/',
failureRedirect: '/test',
failureFlash: true })
);