I’m trying to create a new user in an user admin area of my app. I’m calling a method on the server (not client side because I don’t want to log in as each user I add them). The user gets added, however, the email is not saving. email value exists when passed in.
I’m on Meteor 1.1.0.2 . What is the correct code to save both the username and the email.
Thanks,
Don
Meteor.methods({
createNewUser:function(username,email,password){
var u = {
username:username,
email: email,
password:password
}
var newUserId = Accounts.createUser(u);
return newUserId;
}
});
Seems kind of hard to say based on just that as that code looks correct. Does it work if you run it from the server? Does it work if you run it form the client? What troubleshooting have you tried already?
@Steve , I just logged it on the server. The email does get saved to Meteor.users on the sever. So, the issue now is why is it not updating on the client.
This tells me that autopublish does not publish the email, only the username.
I’ll try rolling my own publish to see if that solves the problem.
That was the problem. I had to write my own publish/subscribe for Meteor.users, in order to get the email. My guess is Meteor considers this a security issue if emails are autopublished.
Just a tip, for cases wheres theres a question of subscriptions / publications, I can highly recommend @msavin’s Mongol package, it has helped me in these exact cases; figuring out whether data is being published or not.