meteor Publishing Data Validating User Account On Publish


Example

Sometimes it's a good idea to further secure your publishes by requiring a user login. Here is how you achieve this via Meteor.

import { Recipes } from '../imports/api/recipes.js';
import { Meteor } from 'meteor/meteor';

Meteor.publish('recipes', function() {
  if(this.userId) {
    return Recipe.find({});
  } else {
    this.ready();  // or: return [];
  }
});