Accounts.createUser not saving email


#1

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;
}

});

#2

I use the same code in my app without any problem. It creates a new user with an unverified email address.


#3

Thanks Steve. What version of Meteor? What packages are you using? I just have accounts-password.

Very strange that I don’t get any errors. I see the username in Meteor.users.find().fetch() on the client console, but not the email.

Might be because my code lives inside a local package, but really shouldn’t matter.

Don


#4

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?


#5

I use v1.1.0.2.
Did you try a Meteor.users.find().fetch() on the server, just in case?


#6

@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.

Thanks,
Don


#7

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.

Appreciate the help!

Don


#8

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.


#9

Thanks for sharing Mongol. If you like the subs feature, you’re going to love what’s coming next.