2023-03-29
2221
#node
Kingsley Ubah
135144
Mar 29, 2023 â‹… 7 min read

Building a simple login form with Node.js

Kingsley Ubah 21. Web Developer. Technical Writer. African in Tech.

Recent posts:

Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 min read
JavaScript logo on top of violet background

Exploring essential DOM methods for frontend development

Learn four groups of DOM methods and their uses to create responsive and dynamic webpages. A helpful DOM reference table is also included.

Chimezie Innocent
Jul 23, 2024 â‹… 12 min read
View all posts

13 Replies to "Building a simple login form with Node.js"

  1. Excellent piece! There’s a little typo, though; under Registering the user, in the second line, you’ve written app.py instead of app.js
    Otherwise the walk-through is excellent

  2. I clone the repository in my WAMP folder and run project by [npm run start] it works! but whenever I go for /register route fill up the form and submit, terminal stop with crash report

    1. Change this code var result = db.query(‘SELECT email FROM users WHERE email = ?’, [email], async (error, res) => {
      To
      var result = db.query(‘SELECT email FROM users WHERE email = ?’, [email], async (error, ress) => {

    1. in the sections such as:
      var result = db.query(‘SELECT email FROM users WHERE email = ?’, [email], async (error, res) => {

      You need to change error,res to error, ress

  3. hello sir, i think there is a mistake in your codes. It is the password!==confirm_password part. When we run this code, the else if part does not run. I didnt understand how can i fix it. Can you help me please

      1. Yes, he says nothing but presumably it’s up to us to add an app.post that compares the hashed password with the one in the db and either accept or reject the login. The problem remains to make the other pages on the site aware that the user is logged in, either by maintaining a session on the server or providing the user with a token. That’s a whole other subject I guess the author did not want to tackle.

  4. In register.hbs (1)do change this “password-confirm” to “password_confirm”,,,,,(2)do change in app.js code where db insert query is written there should be little bit change instead of this “res”..write “result”there (3)in .env folder change this “DATABASE_ROOT” to “DATABASE_USER” (4)remove following code from app.js ” const path = require(“path”)
    const publicDir = path.join(__dirname, ‘./public’)
    app.use(express.static(publicDir))”

Leave a Reply