I’m trying to declare a variable on the top of publication.js file because I’m going to use it over and over again. So because I can’t use Meteor.user() inside any publication function function, I’m trying to declare the following variable:
var curUser = Meteor.users.findOne(this.userId);
This doesn’t produce an error, but it also don’t find the user that’s currently logged in. I need to use a profile field throughout my publications (for certain users based on their roles). I’m not sure how else to do this. NOTE: This works if I repeatedly declare the variable inside each publication function. This produces an error:
var curUser = Meteor.users.findOne(Meteor.userId());
It says that I can’t use Meteor.userId() inside a publication function (even though I’m not using it in that context). I’m really stumped on this issue. I can get around it by repeatedly declaring the same variable over and over again, but I’d prefer not do that.