Updating Meteor.users from client

前端 未结 1 1695
执念已碎
执念已碎 2021-01-27 15:14

I have a form that tried to update meteor.users with extra information about users with the following helper

Template.Profile.events({
  \'submit form\': functio         


        
相关标签:
1条回答
  • 2021-01-27 15:46

    Due to the fact that you are trying to set an attribute directly on the base user object, you are receiving the 'Access denied' error. According to the Meteor documentation for Meteor.users:

    By default, the current user's username, emails, and profile are published to the client.

    This means that you can update any of those user attributes, but if you want to add additional ones, it is best to add them to one of these already existing fields. I would suggest adding something like `firstName' to the profile attribute. In this case, your code would look something like this:

    Meteor.users.update({_id: Meteor.userId()}, {$set: {'profile.firstName': post.firstName}});
    
    0 讨论(0)
提交回复
热议问题