We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cee595b + 0204e45 commit c114cdfCopy full SHA for c114cdf
1 file changed
nextstep-backend/src/services/users_service.ts
@@ -40,6 +40,10 @@ export const getUserById = async (id: string): Promise<UserData | null> => {
40
41
42
export const updateUserById = async (id: string, updateData: Partial<UserData>): Promise<UserData | null> => {
43
+ if (updateData.password) {
44
+ const salt = config.token.salt();
45
+ updateData.password = await bcrypt.hash(updateData.password, salt);
46
+ }
47
const user = await UserModel.findByIdAndUpdate(id, updateData, { new: true }).exec();
48
return user ? userToUserData(user) : null;
49
};
0 commit comments