Accounts.createUser 在 Meteor.methods 中使用时不发送验证电子邮件
Accounts.createUser not sending verification email when used in Meteor.methods
我有一个基本的流星方法可以执行以下操作
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
});
)};
从客户端调用注册是这样的。
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");
}
});
}
这会创建用户,但不会发送验证电子邮件。但是,如果我像这样从客户端创建用户
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");
}
})
电子邮件已发送。
我尝试从服务器端创建用户的原因是因为我想禁用自动登录并允许经过验证的用户登录。
任何有关如何解决此问题的帮助将不胜感激!
谢谢。
如果您创建用户客户端,Accounts 包负责在 Meteor.users 集合中创建用户,然后发送验证电子邮件。
它通过调用服务器方法 createUser
来实现。
如果您像您一样使用自己的方法在服务器端创建新用户,Accounts 包只会创建用户。您必须按照 richsilv 的建议自行发送验证邮件。或者使用其他一些例程将您的验证电子邮件发送给用户。
如果您想深入了解帐户包如何处理此问题,请查看:Accounts packages createUser/verification
我有一个基本的流星方法可以执行以下操作
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
});
)};
从客户端调用注册是这样的。
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");
}
});
}
这会创建用户,但不会发送验证电子邮件。但是,如果我像这样从客户端创建用户
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");
}
})
电子邮件已发送。
我尝试从服务器端创建用户的原因是因为我想禁用自动登录并允许经过验证的用户登录。
任何有关如何解决此问题的帮助将不胜感激!
谢谢。
如果您创建用户客户端,Accounts 包负责在 Meteor.users 集合中创建用户,然后发送验证电子邮件。
它通过调用服务器方法 createUser
来实现。
如果您像您一样使用自己的方法在服务器端创建新用户,Accounts 包只会创建用户。您必须按照 richsilv 的建议自行发送验证邮件。或者使用其他一些例程将您的验证电子邮件发送给用户。
如果您想深入了解帐户包如何处理此问题,请查看:Accounts packages createUser/verification