freeCodeCamp/curriculum/challenges/chinese/06-information-security-and.../advanced-node-and-express/how-to-put-a-profile-togeth...

1.9 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
5895f70ef9fc0f352b528e6b How to Put a Profile Together 2 如何将配置文件放在一起

Description

提醒一下,这个项目是基于Glitch的以下入门项目构建的,或者是从GitHub克隆的。现在我们可以确保访问/ profile的用户已经过身份验证我们可以使用页面上“req.user”中包含的信息继续将包含变量username equaling'req.user.username'的对象传递到配置文件视图的render方法中。然后转到你的'profile.pug'视图并添加第h2.center#welcome Welcome, #{username}!h2.center#welcome Welcome, #{username}!使用“center”类创建h2元素并使用包含文本“Welcome”和用户名的id“welcome”创建同样在配置文件中添加指向/ logout的链接。该路由将托管用于取消身份验证用户的逻辑。 a(href='/logout') Logout当您认为自己正确时,请提交您的页面。

Instructions

Tests

tests:
  - text: 正确地将Pug渲染变量添加到/ profile
    testString: 'getUserInput => $.get(getUserInput("url")+ "/_api/server.js") .then(data => { assert.match(data, /\/views\/pug\/profile[^]*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); })'

Challenge Seed

Solution

// solution required