From 0204e459a73ca221266887cef8255a6bffa85e29 Mon Sep 17 00:00:00 2001 From: Tal Jacob Date: Mon, 2 Jun 2025 08:41:24 +0300 Subject: [PATCH] Hotfix Patch User Password Encryption Signed-off-by: Tal Jacob --- nextstep-backend/src/services/users_service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nextstep-backend/src/services/users_service.ts b/nextstep-backend/src/services/users_service.ts index 266d871..db12f67 100644 --- a/nextstep-backend/src/services/users_service.ts +++ b/nextstep-backend/src/services/users_service.ts @@ -40,6 +40,10 @@ export const getUserById = async (id: string): Promise => { export const updateUserById = async (id: string, updateData: Partial): Promise => { + if (updateData.password) { + const salt = config.token.salt(); + updateData.password = await bcrypt.hash(updateData.password, salt); + } const user = await UserModel.findByIdAndUpdate(id, updateData, { new: true }).exec(); return user ? userToUserData(user) : null; };