gpt4 book ai didi

javascript - Meteor 账户 邮箱验证

转载 作者:行者123 更新时间:2023-12-03 06:23:41 25 4
gpt4 key购买 nike

如何使用自定义消息和自定义 from 参数而不是默认参数向用户发送电子邮件验证。

Meteor.methods({
sendveryficationmail: function (theuserId, themail) {
this.unblock();
Accounts.sendVerificationEmail(theuserId);
}
});

当我使用该方法时,我会收到默认的 meteor 验证电子邮件。如何更改参数以及应该从哪里更改它们?

最佳答案

您可以创建自己的函数来使用模板发送自定义 HTML,您可以将事件传递给简单的 HTML 而不是模板文件。这是代码:

'sendVerificationEmail':function (emailId) {
Meteor.users.update({'emails.address': emailId}, {$unset: {'services.email.verificationTokens': 1}});
var user = Meteor.users.findOne({"emails.address": emailId});
if (user) {
if( user.emails.find(email=> email.address === emailId ).verified ){
throw new Meteor.Error("Email already verified");
} else {
var userInfo = user.profile;
var emailId = user.email[0].address;
Accounts.emailTemplates.siteName = "NJAL";
Accounts.emailTemplates.from = "myTest <community@myTest.com>";
Accounts.emailTemplates.verifyEmail.subject = function(user) {
return "Account Verification Required";
};
Accounts.emailTemplates.verifyEmail.html = function (user, url) {
SSR.compileTemplate( 'registartionEmail', Assets.getText( 'email_templates/registration_confirm.html' ) );
var res=url.split("/");
var emailData = {
"designer_name": userInfo.fname + " "+ userInfo.lname,
"url": "http://domain.com/pages/verify/?token="+res[res.length-2]+"/"+res[res.length-1],
"emailId": emailId,
};
return SSR.render( 'registartionEmail', emailData );
};
Accounts.sendVerificationEmail(user._id, emailId);
}
} else {
throw new Meteor.Error("Email does not exist");
}
},

关于javascript - Meteor 账户 邮箱验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38746917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com