View template changes supporting login/logout

So far, we've created a backend user authentication service, a REST module, to access that service, a router module to handle routes related to logging in and out of the website, and changes in app.mjs to use those modules. We're almost ready, but we've got a number of outstanding changes to make in the templates. We're passing the req.user object to every template because each one must be changed to accommodate whether the user is logged in or not.

In partials/header.hbs, make the following additions:

...    {{#if user}}        <div class="collapse navbar-collapse"            id="navbarSupportedContent">            <span class="navbar-text text-dark col">{{ title }}</span> <a class="btn btn-dark col-auto" href="/users/logout"> ...

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.