as the title says, my user object is losing fields once it reaches the client side.
Here is a list of packages I am using:
Here is my client code. In a template events
var firstname = $("#firstname").val()
var lastname = $("#lastname").val()
var email = $("#email").val()
Meteor.call("createAdmin", firstname, lastname, email, function(error, result) {
if(error) {
console.log("ERROR: " + error);
} else {
console.log(JSON.stringify(result));
}
}
Here is my server code, meteor method:
createAdmin: function(firstname, lastname, email) {
var loggedInUser = Meteor.user()
if (!loggedInUser || !Roles.userIsInRole(loggedInUser, ['dc-admin'])) {
throw new Meteor.Error(403, "Access denied")
} else {
var id;
id = Accounts.createUser({email: email, password: "testpassword",
profile: { first_name: firstname, last_name: lastname }
});
Roles.addUsersToRoles(id, ['dc-admin']);
return Meteor.users.findOne({_id: id});
}
},
If I log the returned result on the client side I get something like this:
{"_id":"7j8RKLXiJZM6QqEkY",
"createdAt":"2015-03-25T23:57:31.859Z",
"services":
{"password":{"bcrypt":"$2a$10$Y3C6wy5Z5nxYbVnjHDRTkeshQOhI3LjEux7s24e/Wc3SOV2e1E/7a"}
},"emails": [{"address":"qweqwe@example.com","verified":false}],
"profile":{
"first_name":"sdfdsfds",
"last_name":"qweqewqe"},
"roles":
["dc-admin"]}
However, once I actually try and fetch the record on the client side, or again on the server, I only get something like this(and keep in mind i have autopublish + insecure still on for development:
{"_id":"7j8RKLXiJZM6QqEkY","profile":{"first_name":"sdfdsfds","last_name":"qweqewqe"}}
If anyone could point out why maybe these emails, roles, and other fields are being deleted once the server side Meteor method has finished executing I'd be really happy!