Set up Passport (Hint)

What is your hint or solution suggestion?
(1) Add passport & express session as a dependency in your package.json:

  • {..., passport: ^0.3.2", "express-session": "^1.15.0"}

Challenge: Set up Passport
(2) Require passport & expression session in your server.js file:

const session = require('express-session');

const passport = require('passport');
(3) Create an .env file and create a variable SESSION_SECRET. Assign it a random value.
(4) In server.js use your SESSION_SECRET variable to compute the hash used to encrypt your cookie,
app.use(session({ secret: process.env.SESSION_SECRET, resave: true, saveUninitialized: true, }));
(4) Use app.use() on passport.initialize() and passport.session();

app.use(passport.initialize()); app.use(passport.session());

Link to the challenge:

1 Like