Export user data

This commit is contained in:
2024-08-14 19:50:21 +08:00
parent c79bb5475d
commit be1c8de5bf
5 changed files with 125 additions and 25 deletions

View File

@@ -90,14 +90,30 @@ router.get("/all", async (req, res) => {
let list = await User.findAll({
where: condition,
order: [["createdAt", "DESC"]],
attributes: { exclude: ["password", "profilePicture"] },
attributes: {
exclude: [
"password",
"profilePicture",
"resetPasswordToken",
"resetPasswordExpireTime",
],
},
});
res.json(list);
});
router.get("/individual/:id", validateToken, async (req, res) => {
let id = req.params.id;
let user = await User.findByPk(id);
let user = await User.findByPk(id, {
attributes: {
exclude: [
"password",
"profilePicture",
"resetPasswordToken",
"resetPasswordExpireTime",
],
},
});
if (!user) {
res.sendStatus(404);
@@ -109,8 +125,6 @@ router.get("/individual/:id", validateToken, async (req, res) => {
message: `ERR_ACC_IS_ARCHIVED`,
});
} else {
user.password = undefined;
user.profilePicture = undefined;
res.json(user);
}
});