fix: issue user's private fields such as password were returned
This commit is contained in:
@@ -16,7 +16,7 @@ module.exports = function (sequelize) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const user = await User.findByPk(userId, {
|
const user = await User.findByPk(userId, {
|
||||||
attributes: ['id', 'username', 'role', 'avatarPath'],
|
attributes: ['id', 'email', 'username', 'role', 'avatarPath'],
|
||||||
});
|
});
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.status(404).send('User not found');
|
return res.status(404).send('User not found');
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ module.exports = function (sequelize) {
|
|||||||
|
|
||||||
router.get('/', verifySignedIn, verifyAdmin, async (req, res) => {
|
router.get('/', verifySignedIn, verifyAdmin, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const users = await User.findAll();
|
const users = await User.findAll({
|
||||||
|
attributes: ['id', 'email', 'username', 'role', 'avatarPath'],
|
||||||
|
});
|
||||||
res.json(users);
|
res.json(users);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ module.exports = function (sequelize) {
|
|||||||
|
|
||||||
const users = await User.findAll({
|
const users = await User.findAll({
|
||||||
where,
|
where,
|
||||||
|
attributes: ['id', 'email', 'username', 'role', 'avatarPath'],
|
||||||
limit: 7,
|
limit: 7,
|
||||||
});
|
});
|
||||||
res.json(users);
|
res.json(users);
|
||||||
|
|||||||
Reference in New Issue
Block a user