I use passport methods in code also, for example in registration in controller I use req.login(). And it works well - user is created without errors. But when I try to login with username and password of this user, I call passport and get the error.
Router:
router.post('/login', passport.authenticate('local', { successRedirect: '/',
failureRedirect: '/login',
failureFlash: true }));
The error in terminal:
Error: Unknown authentication strategy "local"
at attempt (/home/proj/node_modules/passport/lib/middleware/authenticate.js:166:37)
at Object.authenticate [as handle] (/home/proj/node_modules/passport/lib/middleware/authenticate.js:342:7)
at next_layer (/home/projs/node_modules/express/lib/router/route.js:103:13)
at Route.dispatch (/home/proj/node_modules/express/lib/router/route.js:107:5)
at c (/home/proj/node_modules/express/lib/router/index.js:195:24)
at Function.proto.process_params (/home/proj/node_modules/express/lib/router/index.js:251:12)
at next (/home/proj/node_modules/express/lib/router/index.js:189:19)
at next_layer (/home/proj/node_modules/express/lib/router/route.js:77:14)
at next_layer (/home/proj/node_modules/express/lib/router/route.js:81:14)
at Route.dispatch (/home/proj/node_modules/express/lib/router/route.js:107:5)