Skip to content

Commit

Permalink
- Security Fix: Do not publish all of people collection.
Browse files Browse the repository at this point in the history
Thanks to Adrian Genaid !
  • Loading branch information
xet7 committed Jun 12, 2018
1 parent 53bd527 commit dda49d2
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions server/publications/people.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
Meteor.publish('people', (limit) => {
Meteor.publish('people', function(limit) {
check(limit, Number);
return Users.find({}, {
limit,
sort: {createdAt: -1},
});

if (!Match.test(this.userId, String)) {
return [];
}

const user = Users.findOne(this.userId);
if (user && user.isAdmin) {
return Users.find({}, {
limit,
sort: {createdAt: -1},
fields: {
'username': 1,
'profile.fullname': 1,
'isAdmin': 1,
'emails': 1,
'createdAt': 1,
'loginDisabled': 1,
},
});
} else {
return [];
}
});

0 comments on commit dda49d2

Please sign in to comment.