User authentication with sessions

We implemented the functionalities that register new users in our system. The next step is to authenticate these users. Let's first provide an interface to enter a username and password. We need to add a new route handler in frontend/js/app.js:

.add('login', function() {
    var p = new Login();

All the other pages so far use the same idea. We will initialize a new controller and pass it to the showPage helper. The template that is used here is as follows:

// frontend/tpl/login.html <header> <navigation></navigation> </header> <div class="hero"> <h1>Login</h1> </div> <form> {{#if error && error != ''}} <div class="error">{{error}}</div> {{/if}} {{#if success && success != ''}} <div class="success">{{{success}}}</div> ...

Get Node.js By Example 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.