i'm having huge problem meteor.user()
, (i believe) since i'm running server side rendering.
i want subscribe based on user's email, don't know how. here's how subscribe:
const mycomponent = react.createclass({ mixins: [reactmeteordata], getmeteordata() { let data = {} let handle = meteor.subscribe('keypairs', this.props._id) if (handle.ready()) { data.keypair = keypairs.findone() // add data.currentuser = meteor.user() here if need later } }, })
but do if want subscribe based on meteor.user()
, i.e. let handle = meteor.subscribe('keypairs', meteor.user().emails[0].address)
(will not work)?
you should never pass user information client method or subscription since server knows user is!
just do:
meteor.subscribe('keypairs');
and on server:
meteor.publish('keypairs',function(){ const user = meteor.users.findone(this.userid); if ( user ){ const email = user.emails[0].address; ... thing return keypairs.find(query,options); } this.ready(); });
Comments
Post a Comment