Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nextstep-backend/src/services/users_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export const getUserById = async (id: string): Promise<UserData | null> => {


export const updateUserById = async (id: string, updateData: Partial<UserData>): Promise<UserData | null> => {
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;
};
Expand Down
Loading