Skip to main content

--description--

Now that you can ensure the user accessing the /profile is authenticated, you can use the information contained in req.user on your page.

Pass an object containing the property username and value of req.user.username as the second argument for the render method of the profile view.

Then, go to your profile.pug view, and add the following line below the existing h1 element, and at the same level of indentation:

h2.center#welcome Welcome, #{username}!

This creates an h2 element with the class center and id welcome containing the text Welcome, followed by the username.

Also, in profile.pug, add a link referring to the /logout route, which will host the logic to unauthenticate a user:

a(href='/logout') Logout

Submit your page when you think you've got it right. If you're running into errors, you can check out the project completed up to this point.

--hints--

You should correctly add a Pug render variable to /profile.

async (getUserInput) => {
const url = new URL("/_api/server.js", getUserInput("url"));
const res = await fetch(url);
const data = await res.text();
assert.match(
data,
/username:( |)req.user.username/,
'You should be passing the variable username with req.user.username into the render function of the profile page'
);
}