diff --git a/components/user/userService.js b/components/user/userService.js index ddd6dd3..7625d89 100644 --- a/components/user/userService.js +++ b/components/user/userService.js @@ -94,14 +94,13 @@ const loginUser = async (email, password) => { throw new AppError('IncorrectEmailOrPassword', 401, {}) } + // set user password to undefined before sending data + user.password = undefined return { token: signToken(user._id), user } } const getAllUsers = async () => { const users = await User.find({}, null, null) - for (let user of users) { - user.activatedCodes = await codeService.getCodeCount(user._id) - } return users }