DEV Community

Discussion on: How To Build Rest API With NodeJS, Express, and MySQL

Collapse
 
juliest88 profile image
Julia Strichash • Edited

Hi Fernando,
Can you describe the steps you did?
I need more information.
Did you send an email and a password on the body request?

Basically, userLogin method performs the following steps on the user.controller.js file:

  • Check for validation
  • Extract email and password from req.body
  • Use findOne method by email <= (this is where we are using columnSet).
  • If there is no such user with this email => throw HTTP error exception.
  • Checking whether the user input password matches the user password from the DB.
  • If not => throw HTTP error exception.
  • If the user matched => create a token by secretKey
  • Send back the user (without the password) and the token.

Perhaps it's something that needs if block (or something like that),
But I need to see the steps that you have taken.

Thanks! :)