I can’t see any profile information on my users, any idea why?
server :
Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
{fields: {'profile': 1}});
});
Meteor.publish("allUsers", function () {
//TODO: For testing only, remove this
return Meteor.users.find({}, {fields: {'profile': 1}});
});
client :
Meteor.autosubscribe(function () {
Meteor.subscribe('allUsers',null , function() { console.log(Meteor.users.find().fetch()) });
Meteor.subscribe('userData', null, function() { console.log(Meteor.user())});
});
....
Accounts.createUser({email:email,password:password, profile: {name: name}},function(error){
...
});
My console output an object with only _id and emails for the first one and undefined for the second one.
The profile information (name in my case) seems to works because in my server.js I have a name validation that works fine :
Accounts.onCreateUser(function(options, user) {
if(options.profile.name.length<2)
throw new Meteor.Error(403, "Please provide a name.");
return user;
});
Am I missing something?
Thanks!
Found the problem :
In the onCreateUser function , I need to add this the profile information from the options to the user object , so my function should looks like this instead :