people.js 586 B

12345678910111213141516171819202122232425262728
  1. Meteor.publish('people', function(query, limit) {
  2. check(query, Match.OneOf(Object, null));
  3. check(limit, Number);
  4. if (!Match.test(this.userId, String)) {
  5. return [];
  6. }
  7. const user = Users.findOne(this.userId);
  8. if (user && user.isAdmin) {
  9. return Users.find(query, {
  10. limit,
  11. sort: { createdAt: -1 },
  12. fields: {
  13. username: 1,
  14. 'profile.fullname': 1,
  15. 'profile.initials': 1,
  16. isAdmin: 1,
  17. emails: 1,
  18. createdAt: 1,
  19. loginDisabled: 1,
  20. authenticationMethod: 1,
  21. },
  22. });
  23. }
  24. return [];
  25. });