此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/#,BTW我没有使用路由包。
<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>
答案 0 :(得分:0)
最简单的方法是使用某种路由 - 最好是铁路由器:路由器或流路由器。
因此,如果您使用iron:router并为上述模板定义路线“passwordCreate”,您可以致电
Router.go('\passwordCreate?token="+token);
在提供给Accounts.onEnrollmentLink()的回调函数中。
您可以从Router.params中提取此令牌,然后您可以使用docs中指定的Accounts.resetPassword()。