2016-04-28 123 views
0

此Meteor代碼接受來自用戶的電子郵件並在服務器上調用方法createNewUser使用onEnrollmentLink實施sendEnrollmentEmail

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> 

回答

0

最簡單的方法是使用某種路由 - 最好是鐵路:路由器或流量路由器。

所以如果你使用的鐵:路由器和定義上面的模板的路線「passwordCreate」,您可致電

Router.go('\passwordCreate?token="+token); 
在()提供給Accounts.onEnrollmentLink回調函數

您可以從Router.params中提取此令牌,然後您可以使用0123./中指定的Accounts.resetPassword()。

+1

我的問題主要是關於如何在Accounts.onEnrollmentLink()方法中編碼,即放置/使用它的方式以及語法的外觀。 ;) –