1.8 KiB
1.8 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
5895f70ef9fc0f352b528e6b | 如何將 Profile 放在一起 | 2 | 301554 | how-to-put-a-profile-together |
--description--
現在,我們能確保訪問 /profile
頁面的用戶都是經過驗證的,這樣我們就可以在頁面上使用 req.user
裏的信息了。
傳遞一個包含屬性 username
且屬性值爲 req.user.username
的對象,作爲 profile 頁面的 render 方法的第二個參數。 然後在 profile.pug
頁面,將下面的代碼添加到現有的 h1
元素下方,處在同一級別的縮進。
h2.center#welcome Welcome, #{username}!
這樣就創建了一個 h2
元素,具有 'center
' class,和包含文本 'Welcome,
' 的 id 'welcome
',以及 username(用戶名)。
另外,在 profile.pug
中,添加一個指向 /logout
路由的鏈接,它將託管一個未認證用戶的邏輯。
a(href='/logout') Logout
完成上述要求後,請提交你的頁面鏈接。 如果你遇到了問題,可以參考這裏的答案。
--hints--
應在 Pug render 中給 /profile 傳一個變量。
(getUserInput) =>
$.get(getUserInput('url') + '/_api/server.js').then(
(data) => {
assert.match(
data,
/username:( |)req.user.username/gi,
'You should be passing the variable username with req.user.username into the render function of the profile page'
);
},
(xhr) => {
throw new Error(xhr.statusText);
}
);
--solutions--
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/