How to get logged in user id on server?

I want to get logged in user’s id on server so I can publish data belong to that user.

In other words, what is the server-side equivalent of Meteor.userId()?

this.userId is available inside publish functions and Meteor methods.

The server won’t know the userId outside of contexts where the client’s connection is available.

3 Likes