Join Emmanuel Henri to add the registration handlers that will be used to log in a user and his or her corresponding routes.
- [Instructor] Okay, so the next function … that we need to create is the function … for registering new users. … So let's go ahead and keep working on this. … So let's do an export … of a function which we'll call register. … And then this function takes two arguments … so a request and a response. … And then inside of that function, … we'll create first a variable … that we'll call newUser. … And this function will pass a new user, … so remember, we've created a variable here … which basically adds the model user … and passes the schema that we created earlier … and we're going to use this to create a new user. … Like so. … Leveraging what we've created up there. … And we'll pass from the request what is in the body. … So remember, when we make transactions with Postman here, … in the body, we're passing the data to create a new user … and this is what will be in the body of the request … which is here. … So now we'll have the information for the new user … and now we need to create the new user …
- Open Web Application Security Project (OWASP)
- Reasons for using a JSON Web Token (JWT)
- Adding bcrypt password hashing
- Adding handlers for registration and login
- Finalizing secured endpoints
- Testing APIs with Postman