I\'m trying to get my Passport local strategy working.
I\'ve got this middleware set up:
passport.use(new LocalStrategy(function(username, password,
Resolved in my case, I also faced the same problem, but resolved just by reordering the code as mentioned below:
//--------------------------------
previous code :
app.use(flash())
app.use(session({
secret: 'somesecret',
resave: false,
saveUninitialized: false
}))
// using the custom middleware for storing variable in response
app.use((req, res, next) => {
res.locals.isAuthenticated = req.isAuthenticated()
next()
})
app.use(passport.initialize())
app.use(passport.session())
//--------------------------------
Refactored code : (which fixed the problem):
app.use(flash())
app.use(session({
secret: 'somesecret',
resave: false,
saveUninitialized: false
}))
app.use(passport.initialize())
app.use(passport.session())
// using the custom middleware for storing variable in response
app.use((req, res, next) => {
res.locals.isAuthenticated = req.isAuthenticated()
next()
})
//--------------------------------