diff --git a/server/models/user.js b/server/models/user.js index c6d6771b..782a2888 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -21,6 +21,14 @@ const User = { update: async function (userId, updates = {}) { try { + // Rehash new password if it exists as update + // will be given to us as plaintext. + if (updates.hasOwnProperty("password") && updates.password.length >= 8) { + updates.password = bcrypt.hashSync(updates.password, 10); + } else { + delete updates.password; + } + await prisma.users.update({ where: { id: parseInt(userId) }, data: updates,