我希望能够重新发送给我的Meteor应用程序用户的电子邮件验证链接,以防他们意外删除他们的电子邮件验证邮件 .
我有一个id为“resentEmailVerificationLink”的链接
我的客户端中有以下代码,用于单击链接时(警报只是显示自己在错误发生之前获取的函数):
Template.dashboard.events({
'click #resentEmailVerificationLink' : function(event) {
event.preventDefault();
var id = Meteor.userId();
alert('clicked: ' + id);
Accounts.sendVerificationEmail(id);
alert('Verification Email resent');
return false; // Stops page from reloading
}
)};
我知道sendVerificationEmail是一个服务器函数,但我不知道如何在点击验证邮件链接时调用服务器中的这个功能(我有点像流星新手) .
任何想法如何实现这一点,因为目前它不能与以下错误一起使用: Uncaught TypeError: Accounts.sendVerificationEmail is not a function
注意:Meteor.Accounts.sendVerificationEmail(id);也不起作用(但它会产生不同的错误 .
1 回答
您可以尝试使用服务器端方法只创建一个传递attrs并在服务器上调用http://docs.meteor.com/#/full/accounts_sendverificationemail . 关于流星方法的更多信息:http://docs.meteor.com/#/full/meteor_methods