Meteor User Property

前端 未结 2 1493
说谎
说谎 2021-02-10 09:40

I\'d like to be able to mark users as \"admin\" in the Meteor auth system, and allow that user to do special things, as well as show some gui elements I wouldn\'t show if they w

2条回答
  •  执念已碎
    2021-02-10 09:44

    To anyone in the future, simply assign the value in the users table in the database. You can publish additional fields to the user using the following:

    Meteor.publish("userData", function () {
         return Meteor.users.find({_id: this.userId}, {fields: {'admin': 1}});
    });
    

    And on the client:

    Meteor.subscribe("userData");
    

    Poof. Straight from the documentation.

提交回复
热议问题