nodes passport Error: Unknown authentication strategy “local-login”

后端 未结 2 1407
别跟我提以往
别跟我提以往 2021-01-14 19:22

I have been trying to get local authentication work with passport on nodejs and as far as i can tell all of my code it is correct but i keep getting the same annoying error

相关标签:
2条回答
  • 2021-01-14 19:53

    I also had the same problem but when I put this line of code after the app.use(flash()) it worked:

    app.use(passport.initialize());
    app.use(passport.session());
    app.use(flash());
    require('./config/passport')(passport);
    
    0 讨论(0)
  • 2021-01-14 20:19
    require('./config/passport')(passport);
    

    Change the path of the file. Without this working, passport's configurations will not be passed to the routes.

    Here is a snippet of where the line should be located:

    // server.js
    
    // configuration
    ===============================================================
    mongoose.connect(configDB.url); // connect to our database
    
    require('./config/passport')(passport); // pass passport for configuration
    
    0 讨论(0)
提交回复
热议问题