passport's req.isAuthenticated always returning false, even when I hardcode done(null, true)

前端 未结 14 1447
小鲜肉
小鲜肉 2020-11-29 02:06

I\'m trying to get my Passport local strategy working.

I\'ve got this middleware set up:

passport.use(new LocalStrategy(function(username, password,         


        
14条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 02:25

    If you wrap your routes like so:

    module.exports = function(){
    
    router.get('/',(req,res)=>{
     res.send('stuff');
      }
    
    }
    

    You have to pass "app and passport" to your routes like so:

    module.exports = function(app,passport){
    
    //routes n stuff
    
    }
    

提交回复
热议问题