Meteor - Accessing user fields from client -


i use usernames new accounts instead of emails. have added feature allows users add email subscribe notifications.

to add emails use method on server:

addemail: function (email) {   if (! meteor.userid()) {     throw new meteor.error("not-authorized");   }   roles.adduserstoroles(meteor.userid(), 'subscriber');   meteor.users.update(meteor.userid(), { $set: { email: email } }); } 

i want email field accessible client. tried publishing user client this.

meteor.publish("userdata", function() {   if (this.userid) {     return meteor.users.find(       {_id: this.userid},       {fields: {email: 1}     });   } }); 

ideally publish current user it's email client.

here client side subscribe: meteor.subscribe("userdata");

now here question, how access data (email string) client side? , can method used different fields?

thanks!

any fields existing client/server collection selectively publish typically published original mongo collection , accessible there. in case, meteor.user() or meteor.users.find(meteor.userid()) return user collection. meteor.user().email should available each client field.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -