1qk1 / productivity-platform

Open Source productivity platform in the making
https://prodapp.xyz/
MIT License
3 stars 0 forks source link

Replace find-edit-save() pattern, fix wrong password bug #111

Closed 1qk1 closed 5 years ago

1qk1 commented 5 years ago

Replaced all findByid-edit-save() logic on the models with findByIdAndUpdate(). This cleans up the code and fixes another bug that hashes the user's password everytime you do User.find execute some logic, edit some data and then user.save() for example, because of the User.pre('save') middleware on the user's model which is used to hash the user's password before saving the user in the database.