I have the following in my publish.js file I’m trying to return all the topics that belong to that user (current logged in user)
Meteor.publish('topics' , function() {
return Topics.find({$or:[{userId: this.userId},{collaboratorsIds: this.userId},{inviteeId:this.userId}]});
});
This works great however there is a security hole, if the user is not logged all the topics are published I tried the following which fixes but now my app hangs on the sub waiting for publish to return something
Meteor.publish('topics' , function() {
if(this.userId)
return Topics.find({$or:[{userId: this.userId},{collaboratorsIds: this.userId},{inviteeId:this.userId}]});
});
I tried adding this.ready or return []; but that does nothing what’s the correct approach