Join Emmanuel Henri to add the login handlers that will be used to log in a user.
- [Instruction] So the final function that we can use for … our user controllers is the login function. … So basically allowing to login into the API's … and once we're logged in, then we can go ahead … and do transactions with the API. … So let's go ahead and do that function … so we're going to call this log in. … So you create a new function … and then the arguments again … are the request and the response. … And then what we're going to do is go ahead and try to find … a user in the database. … So findOne. … So basically, what we need to do is … grab the email from the request .body … .email. … So again in the request, we're going to have an email … that we'll try to match to … something that we have in our database. … So what we'll do and you want to go after the curly brace … before the parenthesis, is do a comma … and then go ahead and do an error and user … and then what we'll do is keep going with a new function … to check if there's a new user. … So if we get an error, … we'll throw the error. …
- 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