1.9 KiB
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
5895f70ef9fc0f352b528e6b | Mettere insieme un profilo | 2 | 301554 | how-to-put-a-profile-together |
--description--
Ora che possiamo garantire che l'utente che accede al /profile
sia autenticato, possiamo utilizzare le informazioni contenute in req.user
sulla nostra pagina!
Passa un oggetto contenente la proprietà username
e il valore di req.user.username
come secondo argomento per il metodo render della vista del profilo. Quindi, vai alla tua vista profile.pug
, e aggiungi la seguente riga sotto l'elemento h1
esistente, e allo stesso livello di indentazione:
h2.center#welcome Welcome, #{username}!
Questo crea un elemento h2
di classe 'center
' e con id 'welcome
' contenente il testo 'Welcome,
' seguito dal nome utente.
Inoltre, in profile.pug
, aggiungi un link relativo alla rotta /logout
, che ospiterà la logica per disconnettere un utente.
a(href='/logout') Logout
Invia la tua pagina quando pensi di averlo fatto correttamente. Se dovessi incontrare degli errori, puoi controllare il progetto completato fino a questo punto qui.
--hints--
Dovresti aggiungere correttamente una variabile di rendering Pug a /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.
*/