<sectionid="description"> Como recordatorio, este proyecto se está construyendo sobre el siguiente proyecto de inicio en <ahref="https://glitch.com/#!/import/github/freeCodeCamp/boilerplate-advancednode/">Glitch</a> , o clonado desde <ahref="https://github.com/freeCodeCamp/boilerplate-advancednode/">GitHub</a> . Crear la lógica de cierre de sesión es fácil. La ruta simplemente debe no autenticar al usuario y redirigir a la página de inicio en lugar de mostrar cualquier vista. En el pasaporte, la no autenticación de un usuario es tan fácil como llamar a <code>req.logout();</code> antes de redirigir <pre> app.ruta ('/ logout')
.get ((req, res) => {
req.logout ();
res.redirect ('/');
}); </pre> Es posible que haya notado que tampoco estamos manejando páginas faltantes (404), la forma común de manejar esto en Node es con el siguiente middleware. Continúa y agrega esto después de todas tus otras rutas: <pre> app.use ((req, res, next) => {
estado de res. (404)
.teclee el texto')
.send ('No encontrado');
}); </pre> Envía tu página cuando creas que lo has hecho bien. </section>
testString: 'getUserInput => $.get(getUserInput("url")+ "/_api/server.js") .then(data => { assert.match(data, /req.logout/gi, "You should be call req.logout() in youre /logout route"); }, xhr => { throw new Error(xhr.statusText); })'
- text: Cerrar sesión debe redirigir a la página de inicio /
testString: 'getUserInput => $.get(getUserInput("url")+ "/logout") .then(data => { assert.match(data, /Home page/gi, "When a user logs out they should be redirected to the homepage"); }, xhr => { throw new Error(xhr.statusText); })'