Skip to content

Commit

Permalink
Rehash password for admin-user pwd updates (#398)
Browse files Browse the repository at this point in the history
resolved #397
  • Loading branch information
timothycarambat authored Nov 27, 2023
1 parent 29d3c60 commit 55d319b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 55d319b

Please sign in to comment.