O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The authentication logic

Let's create a simple authentication logic. The backend expects a username and password with the value of the administrator. If these values are provided, it will return a valid token; otherwise, it will return null. Apply the following changes to the code:

const express = require('express')const api = express.Router()const logIn = (username, password) => {    if (username === 'admin' && password === 'admin') {        const userData = {            name: "Admin"        }                return generateToken(userData)            }    return null}api...

The code is very straightforward. First, we compare the value in a simple if conditional, and we created a userData object, which will contain the user information, in this case just a name value is provided. Finally, we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required