【问题标题】:implementing sendEnrollmentEmail with onEnrollmentLink使用 onEnrollmentLink 实现 sendEnrollmentEmail
【发布时间】:2016-08-23 16:11:24
【问题描述】:

此 Meteor 代码接受来自用户的电子邮件并调用服务器上的方法 createNewUser

Meteor.methods({
  'createNewUser': function (email) {
    const userId = Accounts.createUser({email: email, password: 'dummy'});
    Accounts.sendEnrollmentEmail(userId);
  }
});

我收到一封包含此链接的电子邮件

http://localhost:3000/#/enroll-account/6I-arlzO2Kpz4N4KOtb_8UOO1dR_YrKbparLjsF9PNd

如何使用Accounts.onEnrollmentLink() 显示我为接受密码而制作的模板,因为现在它只带我到http://localhost:3000/#,顺便说一句,我没有使用路由包。

<template name="passwordCreate">
<h5>Please create a password for your account</h5>
  <input type="text" name="pswrd1" placeholder="Enter a password">
  <input type="text" name="pswrd2" placeholder="Re enter the password">
</template>

【问题讨论】:

    标签: meteor


    【解决方案1】:

    最简单的方法是使用某种路由 - 最好是 iron:router 或 flow-router。

    所以如果你使用 iron:router 并为上面的模板定义一个路由“passwordCreate”,你可以调用

    Router.go('\passwordCreate?token="+token);
    

    在提供给 Accounts.onEnrollmentLink() 的回调函数中。

    您可以从 Router.params 中提取此令牌,然后您可以将其与 docs 中指定的 Accounts.resetPassword() 一起使用。

    【讨论】:

    • 我的问题主要是关于如何在Accounts.onEnrollmentLink() 方法中编码,即在哪里放置/使用它以及语法的外观。 ;)
    猜你喜欢
    • 2016-09-04
    • 2015-03-10
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 2020-01-25
    • 2010-09-19
    • 2017-02-01
    相关资源
    最近更新 更多