To fix req.user Undefined with Node, Express and Passport, we add the Passport middlewares.
For instance, we write
app.use(session({ secret: "anything" }));
app.use(passport.initialize());
app.use(passport.session());
to add Passport into our Express app by calling app.use
with the middlewares returned by passport.initialize
and passport.session
.