Wrong behavior ensureAuthenticated challenge test

Update: this solved it for me: Advanced Node and Express - Create New Middleware

Same, going to /profile in the browser redirects to /, as it should.
Tests fail.

function ensureAuthenticated(req, res, next) {
  if (req.isAuthenticated()) {
    return next();
  }
  console.log('???????????') //this gets printed to the console
  res.redirect('/');
};


  app
 //.route('/profile')
 .get('/profile',ensureAuthenticated, (req,res) => {
      console.log('!!!!!!!!!!!!!!!!!!!!!!!!')
    res.render(process.cwd() + '/views/pug/profile');
 });
1 Like