[英]Accounts.createUser not sending verification email when used in Meteor.methods
我有一個基本的流星方法,可以執行以下操作
服務器/methods.js
Meteor.methods({
createUserAccount: function(user) {
return Accounts.createUser(user);
}
});
服務器/init.js
Meteor.startup(function() {
process.env.MAIL_URL = ""//removed for SO;
Accounts.config({
sendVerificationEmail:true,
forbidClientAccountCreation: true
});
)};
從客戶那里注冊就是這樣。
客戶端/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");
}
});
}
這將創建用戶,但是不會發送驗證電子郵件。 但是,如果我要像這樣從客戶端創建用戶
客戶端/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");
}
})
電子郵件被發送。
我嘗試從服務器端創建用戶的原因是因為我想禁用自動登錄並允許經過驗證的用戶登錄。
任何有關如何解決此問題的幫助將不勝感激!
謝謝。
如果創建用戶客戶端,則“帳戶”包將負責在Meteor.users集合中創建用戶,然后發送驗證電子郵件。 通過調用服務器方法createUser
。
如果像您一樣使用自己的方法創建新的用戶服務器端,則“帳戶”包將僅創建該用戶。 您必須按照richsilv建議自己發送驗證電子郵件。 或者使用其他一些例程,這些例程會將您的驗證電子郵件發送給用戶。
如果您想對Accounts程序包如何處理有一些了解,請看一下: Accounts程序包createUser / verification
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.