(1) Pass a value of true for showLogin to the index file through res.render("filePath", { variableName: "value"})
so that you can see the login form.
(2) Create a POST request with route /login
. When you try to login you post your username & password to /login
(3) Pass as middleware: passport.authenticate('local', { failureRedirect: '/' })
to the POST request you made in #2. This middleware will allow you to authenticate on this route.
(4) Finally, make a GET request for the /profile
route that will render /views/pug/index
if the user is authenticated. This code will be similar to your original rendering of the ‘index’ view at the start of this challenge.
Challenge: How to Use Passport Strategies
Link to the challenge: