FIX: getAllUsers logic

This commit is contained in:
MohammadHMazarei
2024-12-24 20:08:59 +03:30
parent 3faa550b1c
commit a8891f4096
+2 -3
View File
@@ -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
}