Advanced Node and Express - How to Use Passport Strategies

Hello
I can’t validate this part of the exercice :

A POST request to /login should correctly redirect to /.

So I wanted to know if I understood the code correctly.
And why i can’t validate the excercise.

    /* !!! Ajout de la route login qui accepte une requete post pour s'authentifier et de l'argument failureRedirect vers la route / profile !!! */
    app.route('/login').post(passport.authenticate('local', { failureRedirect: '/' }), (req, res) => {
    res.redirect('/profile');
  });
  
 
  app.route('/profile').get((req, res) => {
    res.render(process.cwd() + '/views/pug/profile');
  });

So the code above mean than we add a route to login where the middleware passeport verify if the userName and Password math together.

If yes we go on the route /profile who show the view template of /views/pug/profile

And if the password and the userName does not match we will redirect the user to /

I have understood the exercice ?
Do you know why i can’t validate it ?

Your project link(s)

solution: boilerplate-advancednode - Node.js Repl - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

Challenge: Advanced Node and Express - 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.