From a8891f409629c1cf8e06fdac0daa99a6373ac697 Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Tue, 24 Dec 2024 20:08:59 +0330 Subject: [PATCH] FIX: getAllUsers logic --- components/user/userService.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 }