I have a basic meteor method that does the following
server/methods.js
Meteor.methods({
createUserAccount: function(user) {
return Accounts.createUser(user);
}
});
server/init.js
Meteor.startup(function() {
process.env.MAIL_URL = ""//removed for SO;
Accounts.config({
sendVerificationEmail:true,
forbidClientAccountCreation: true
});
)};
from the client the registration is called like this.
client/register.js
'submit #app-register-user': function(e,t){
e.preventDefault();
var user = {
username: t.find('#app-username').value,
email: t.find('#app-email').value,
password: t.find('#app-password').value,
profile:{
name: t.find('#app-username').value
}
};
Meteor.call('createUserAccount', user, function(error) {
if(error){
alert(error);
}
else{
$("#joinModal").modal("hide");
}
});
}
This creates the user, however no verification email is being sent. However if I was to create the user from the client side like so
client/register.js
Accounts.createUser({
username: t.find('#app-username').value,
email: t.find('#app-email').value,
password: t.find('#app-password').value,
profile:{
name: t.find('#app-username').value
}
},function(err){
if(err){
alert("something went wrong "+ err);
}
else{
$("#joinModal").modal("hide");
}
})
the email gets sent.
The reason why I'm trying to create the user from the server side is because I want to disable auto-login and allow users who are verified to login.
Any help on how to solve this would be greatly appreciated!
Thank you.
If you create a user client side, the Accounts package takes care of creating the user in the Meteor.users collection and afterwards sending the verification email.
It does so by calling the server method createUser
.
If you create a new user server side by using your own method like you do, Accounts package only creates the user. You have to send the verification email yourself as richsilv suggested. Or use some other routine that will get your verification email sent to the user.
If you want to have some insight on how the Accounts package handles this, have a look at: Accounts packages createUser/verification