Solution for Passport Strategies

Step 1
Add a new variable to show the form

res.render('pug', {
      title: 'Connected to Database',
      message: 'Please login',
      showLogin: true
    });

Step 2
add passport.authenticate() middleware to the existing login route, then redirect the user to GET profile

  app.route("/login").post(passport.authenticate('local', { failureRedirect: '/' }),
  (req, res) => {
    res.redirect('/profile' + req.user);
  })

Step 3
Create a new route to handle the request

app.route("/profile").get((req, res) => {
    res.render('pug/profile');
  })

Challenge: How to Use Passport Strategies

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.