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

前端 未结 14 1398
小鲜肉
小鲜肉 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:32

    I also had the same problem, could not find any solution on the web but i figured it out.

    app.use(require("express-session")({
    secret: "This is the secret line",
    resave: false,
    saveUninitialized: false
    }));
    app.use(passport.initialize());
    app.use(passport.session());
    app.use(bodyParser.urlencoded({extended: true}));
    

    express-session requirement and use should be before any other use. Try this i am sure this would work, worked for me!!

提交回复
热议问题