Create a new user without password (reservation page)

536 views
Skip to first unread message

Adam Girton

unread,
May 24, 2013, 1:07:42 AM5/24/13
to meteo...@googlegroups.com
Hello,

I'm creating a reservation page for my app where the user can enter an email and username before the app goes live. I have explored a few different options. One option would be to use the createUser on the client and just generate a random password that they can change when the app is live. Another is to insert the users info into the Meteor.users collection. My concern with the second option is what would happen when the user creates a password for the first time, all of the fields of the typical Meteor user won't/may not line up. An additional thought is to suppress the verification email when creating the user with createUser.  

Any help with this would be much appreciated!

- Adam

Nate Strauser

unread,
May 24, 2013, 9:18:21 AM5/24/13
to meteo...@googlegroups.com
i would suggest that you create a method that only executes server side (eg lives somewhere like /server/lib/methods.js) - then create your user with a call like so

Accounts.createUser(<user data without password>)  
//this needs to be done server side so you can leave the password blank
//this does not send any emails - emails can later be sent by calling sendVerificationEmail or sendEnrollmentEmail
//this will create users without passwords, who can not log in

then later when you are ready to have users enter the system, you can use this

Accounts.sendEnrollmentEmail(user, email);
//this will send them an email that will let them enroll and set their password

from the docs:
To create an account without a password on the server and still let the user pick their own password, call createUser with the email option and then callAccounts.sendEnrollmentEmail. This will send the user an email with a link to set their initial password.

i use this pattern in my app where we have an 'invite then enroll' setup instead of the more traditional 'self service registration' - works very well for us

i wouldnt go outside of the existing meteor methods for this with some manual insert of data - meteor supports exactly what you want to do already

Adam Girton

unread,
May 24, 2013, 7:05:42 PM5/24/13
to meteo...@googlegroups.com
Ahh perfect! After re-reading the docs that makes sense now. Thank you for your help Nate!
Reply all
Reply to author
Forward
0 new messages