passport local strategy not getting called

前端 未结 14 779
夕颜
夕颜 2020-12-13 04:31

I\'m sure I\'m missing something really obvious here, but I can\'t figure this out. The function I\'ve passed to the LocalStrategy constructor doesn\'t get called when the l

14条回答
  •  [愿得一人]
    2020-12-13 05:06

    I encountered the same problem when I set up my own route handler from which I called passport.authenticate (). I forgot that passport.authenticate returns middleware that must be invoked, so just calling passport.authenticate isn't sufficient. Then I replaced

    router.post("/",
     function(req,res,next){
       passport.authenticate("local", function(err, user, info){
    
        // handle succes or failure
    
      }); 
    })
    

    with

    router.post("/",
     function(req,res,next){
       passport.authenticate("local", function(err, user, info){
    
        // handle succes or failure
    
      })(req,res,next); 
    })
    

提交回复
热议问题