Q:

Meteor: how to access another user's details?

Meteor.users.findOne() gives me back my user document.
Meteor.users.findOne({_id: 'my ID'}) gives me back my user document.
Meteor.users.findOne({_id: 'another users's ID'}) gives me back UNDEFINED.
This is obviously restricted by security. But how can I access another users's account details e.g. _id, name, profile, etc?

A:

You'll need to add a publisher for the user. Here's an example:
// The user fields we are willing to publish.
const USER_FIELDS = {
  username: 1,
  emails: 1,
};

Meteor.publish('singleUser', function (userId) {
  // Make sure userId is a string.
  check(userId, String);

  // Publish a single user - make sure only allowed fields are sent.
  return Meteor.users.find(userId, { fields: USER_FIELDS });
});

Then on the client you can subscribe like this:
Metor.subscribe('singleUser', userId);

or use a template subscription like this:
this.subscribe('singleUser', userId);

Security notes:

Always check the arguments to your publishers, or clients can do bad things like pass {} for userId. If you get an error, make sure you meteor add check.
Always use a fields option with the users collection. Otherwise you'll publish all of their secrets. See the "Published Secrets" section of common mistakes.

