So I'm creating a user profile pages, and have gotten all the data for the current user working fine. the issue I'm having is that the current user can't see other users data.
I've looked at everything I can find on the web but haven't find an answer that has helped me, just many different ways of doing one thing.
my publish
Meteor.publish('allUsers', function(user){
return Meteor.users.find({_id: this.userId},{
fields: {
profile: 1,
emails:1,
username: 1
}
});
});
my router
Router.route('/profile/:_id', {
name: 'profile',
waitOn: function(){
return Meteor.subscribe('allUsers')},
data: function(){
var user = this.params._id;
return Meteor.users.findOne({_id: user});
},
});
profile template
<template name='profile'>
Username: {{username}}<br>
Email: {{email}}
{{log}}
{{#with profile}}
Full Name: {{name}}
{{log}}
{{/with}}
</template>
helper
Template.profile.helpers({
name: function(){
return this.name;
},
username: function(){
return this.username;
},
email: function(){
return this.emails[0].address;
},
log: function(){
console.log(this);
}
});
and this is how I'm linking to other users
<a href="/profile/{{owner}}">{{username}}</a>
owner being the users _id:
the log output for the current user is showing the data though the log output of the other user is an empty object. though it is grabbing the right _id.