Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor AccountTemplates/UserAccounts-如何在电子邮件验证中运行代码?_Meteor_Iron Router_Meteor Useraccounts - Fatal编程技术网

Meteor AccountTemplates/UserAccounts-如何在电子邮件验证中运行代码?

Meteor AccountTemplates/UserAccounts-如何在电子邮件验证中运行代码?,meteor,iron-router,meteor-useraccounts,Meteor,Iron Router,Meteor Useraccounts,我有一些代码,我想在用户验证他们的电子邮件后运行 我该把它放在哪里 我能想到的唯一地方是重定向路由,但这有点不太妥当,依赖于等待重定向发生的用户。我用的是铁制路由器 这是我第一次尝试,但重新计算功能是服务器端的 AccountsTemplates.configureRoute('verifyEmail', { redirect: function(){ var user = Meteor.user(); if (user) { user.recalculateSi

我有一些代码,我想在用户验证他们的电子邮件后运行

我该把它放在哪里

我能想到的唯一地方是重定向路由,但这有点不太妥当,依赖于等待重定向发生的用户。我用的是铁制路由器

这是我第一次尝试,但重新计算功能是服务器端的

AccountsTemplates.configureRoute('verifyEmail', {
  redirect: function(){
    var user = Meteor.user();
    if (user) {
      user.recalculateSignUpReputation();
      Router.go('home');
    }
  }
});

但这似乎太过分了。我更喜欢活动。解决方案1对我不起作用。

谢谢你的评论。最后我做了这个

AccountsTemplates.configureRoute('verifyEmail', {
  redirect: function(){
    var user = Meteor.user();
    if (user) {
      Meteor.call('recalculateSignUpReputation');
      Router.go('home');
    }
  }
});

它在客户端工作,并调用服务器端代码。不可怕,但很有效。如果您有不同的/更好的方法,我会将其标记为正确答案。

您不能直接将其放入电子邮件验证路径吗?i、 e.用户单击其电子邮件中的链接,当该路由在您的站点上执行时,您会触发任何必要的操作?@BrettMcLain UserAccounts/AccountsTemplates正在管理该路由,除非我弄错了。你是什么意思?如何使用和挂接用户对象的更新?您可以观察
verified
标志从false变为true。