Advanced Node How to Put a Profile Together

Hello everyone. I cannot pass the following test:
You should be passing the variable username with req.user.username into the render function of the profile page.
And here is my code:'/login', passport.authenticate('local', {failureRedirect:"/"}), (req,res)=>{
  app.get('/profile', ensureAuthenticated, (req,res)=>{
    res.render(process.cwd()+ "views/pug/profile", {username: req.user.username});

Any help will be much appreciated. Thank you in advance.

user is a property added to the req object by passport.js after a user successfully authenticates.

@AndrewAS, is the /profile route passing through the ensureAuthenticated middleware ? does console.log(req.user) log the authenticated user in the /profile route, if not then check the ensureAuthenticated middleware and why it may be holding up the route

1 Like

Thank you so much. I found out I had a typo in the ensureAuthenticated function.