Files

1.9 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5895f70ef9fc0f352b528e6b Cómo elaborar un perfil 2 301554 how-to-put-a-profile-together

--description--

Ahora que podemos asegurarnos de que el usuario que accede al /profile está autenticado, ¡podemos utilizar la información contenida en req.user en nuestra página!

Pasa un objeto que contenga la propiedad username y el valor de req.user.username como segundo argumento para el método render de la vista de perfil. Luego, ve a tu perfil profile.pug y agrega la siguiente línea debajo del elemento existente h1 y al mismo nivel de indentación:

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

Esto crea un elemento h2 con la clase 'center' e id 'welcome' conteniendo el texto 'Welcome,' seguido por el nombre de usuario.

Además, en profile.pug, añade un enlace que haga referencia a la ruta /logout, que alojará la lógica para des-autentificar a un usuario.

a(href='/logout') Logout

Envía tu página cuando creas que lo has hecho bien. Si te encuentras con errores, puedes revisar el proyecto completado hasta este punto aquí.

--hints--

Debes agregar correctamente una variable de renderizado 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.
*/