[Solved] Enrolling Users on the Server

https://www.meteor-tuts.com/chapters/1/users.html

So if you look at the following code (pulled from the documentation above)

let userid = Accounts.createUser({
    email: 'user@withoutPassword.com'
})

//this will return the newly created _id

Accounts.sendEnrollmentEmail(userid);

This can be run through the meteor shell, but I cant seem to run the same code on the server (in a meteor method). It will raise the following error “[Error: options.password must be a string]”

Is this only meant to be run through a Meteor shell script to do like a bulk enrollment through the shell?

Or can I set up an admin portal in my app that allows this functionality as well?

Are you sure this method is only running on the server - you’ve not accidentally put it in a file which is also imported to the client? Is that error reported on the server or client?

The error message "Error: options.password must be a string" is only found in the client version of password_client.js/Accounts.createUser().

The server version would throw a different error.

1 Like

awesome, thanks for showing me the source for the server version of the createUser function. It seems like it should only be running on the server, but now I suspect something is up with it. Ill report back when I have fix in place. Thank you tho. I am trying to build a login/account mgmt system in a vue app. So this is the first time I am not using the UI pakage to just take a massive shortcut

Yea, the issue was I was using a validated method instead of using the original Meteor method. So i swapped it out and then in the body of the Meteor method it called the server’s createUser function.

1 Like