Search⌘ K
AI Features

Implementing Sign-Up

Explore how to build a secure sign-up feature in NestJS by validating user input, hashing passwords with bcrypt including salt generation, and managing unique email constraints. Understand password security issues and how to protect user data during registration.

Having successfully set up all the essential user and authentication (auth) files, we’re ready to delve deeper. In this lesson, we will learn the sign-up process, ensuring users experience a seamless registration for our virtual library.

Sign-up form
Sign-up form

Defining SignUpDto

To register in our virtual library, users will need two essential pieces of information: email and password. To maintain the integrity of our system, we must ensure users provide both fields during the registration process.

Here are the requirements:

  • The value provided for email should be a valid email address.

  • The password should have a minimum length of 8 characters and a maximum length of 32 characters.

Based on these requirements, try to complete the SignUpDto:

Defining SignUpDto

Defining the signUp method in AuthService

The next step is to define the signUp method responsible for registration logic in AuthService.

Defining the signUp method in AuthService

Within the signUp method, we extract the email and password from SignUpDto ...