From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Hashing the password on sign-up

Hashing the password on sign-up

Alright, so now we are going to hash the user password and store it inside the database. And for that we are going to use the bcrypt library. We are going to target the signup route, because when the user signs up, that's when we want to hash the password. Now at the moment, when we try to sign up the user, it redirects the page to login, indicating that the user is signed up. But actually they are not getting signed up. If we look at the users table, there we can see it shows an empty set. This is because the middleware is applied for the signup route for the post request, and it is waiting for the token to be verified. So first inside the app module, we will exclude the post signup route, which is this one. Inside the exclude method, I'll give the path as user slash signup and method to request method dot post. Let's save this and try to sign up the user again. I'll fill up the credentials and sign up. Let's check the database and the user record is inserted. Now as you can notice…

Contents