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();  // 或:return [];
  }
});