joshuaalpuerto / node-ddd-boilerplate

Node DDD Boilerplate
https://joshuaalpuerto.github.io/node-ddd-boilerplate/#/
Other
724 stars 147 forks source link

bcrypt.compareSync(password, encodedPassword) always returns false #47

Closed ytimocin closed 3 years ago

ytimocin commented 5 years ago

First of all, thank you very much for this boilerplate. Helped me a lot.

My problem is that after registering a user, when trying to get a token with the credentials bcrypt.compareSync(password, encodedPassword) always returns false.

Am I missing something? I have tried it with a lot of different users but nothing works for now.

const comparePassword = (password, encodedPassword) => {
  return bcrypt.compareSync(password, encodedPassword)
}

All I can think of is that user.password in postgres might be text and somehow text and string comparison doesn't work as expected?

joshuaalpuerto commented 5 years ago

Hey @ytimocin, glad this boilerplate helped you. 🎉

To answer your question I tried changing the migration and model file of User password property from STRING to TEXT and the test still passing. On your env file have you set the SECRET value?