cashflow-dev / rest-api-backend

REST API for the Cashflow application
GNU General Public License v3.0
0 stars 0 forks source link

User Model pre-save hook & comparePassword method #18

Closed JohanG2012 closed 5 years ago

JohanG2012 commented 5 years ago

User passwords should be encrypted with bcrypt: https://www.npmjs.com/package/bcrypt

Add a pre-save hook to the User models which encrypt the password.

Add a comparePassword method to the model which allows for a password to be compared with the stored hash.

More info see the first answer here: https://stackoverflow.com/questions/14588032/mongoose-password-hashing