1

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)
Drupal Noob
  • 153
  • 6
  • Any luck here? I'm having the same issue, I can sign up with the strategy, but when i use the built in passport.authenticate model to sign in, i get this error. Is there a require missing or something? – theSiberman Jan 22 '16 at 05:07
  • @theSiberman unfortunately I didn't manage to find any solution :( If you find, please, add your comment here. – Drupal Noob Feb 02 '16 at 14:10
  • I did eventually get around this, but i can;t remember how sorry. After attacking the boilerplate of MEAN for a while, and learning heaps, I've decided to now go with the framework generator MeanJS (not MeanIO) as it comes with all this auth set up for you, including Oauth. I highly recommend checking it out, – theSiberman Feb 18 '16 at 01:50
  • @theSiberman thanks for your suggestion – Drupal Noob Mar 18 '16 at 09:29

0 Answers0