Implementing Sign-Up
Learn how to implement sign-up in NestJS.
We'll cover the following...
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.
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
emailshould be a valid email address.The
passwordshould have a minimum length of 8 characters and a maximum length of 32 characters.
Based on these requirements, try to complete the SignUpDto:
Defining the signUp method in AuthService
The next step is to define the signUp method responsible for registration logic in AuthService.
Within the signUp method, we extract the email and password from SignUpDto and use the save method of
this.userRepository to persist the user in our database.
If a user tries ...