people.js 614 B

1234567891011121314151617181920212223242526272829
  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. importUsernames: 1,
  22. },
  23. });
  24. }
  25. return [];
  26. });