-1

情况:

  • 我在 Meteor 应用程序中使用 React。
  • 我的身份验证包:accounts-password;useraccounts:core
  • 我还使用在我的反应组件gadicc:blaze-react-component中呈现{{> atForm }}模板 =><Blaze template="atForm" />

问题:

我不知道什么应该是正确的语法来保护用户帐户指南中描述的特定页面, 但使用 react

假设我想安全地<Mypage />从“./mypage.jsx”导入

我如何调用{{> ensureSignedIn template="myTemplate"}}和替换“ myTemplate”<Mypage />

我试过<Blaze template="atForm" template={Mypage} />没有成功...

甚至有可能做这样的事情吗?

4

2 回答 2

0

您可以签Meteor.userId()ComponentWillMount()、设置状态并签入render()。或在路由器中使用某种检查

于 2017-06-08T08:28:09.877 回答
0

我找到了一个解决方案:

使用kadira:flow-routerMeteor 的包,使用react-layoutand useraccounts:flow-routing,我可以做这样的事情:

FlowRouter.route('/private', {
  triggersEnter: [AccountsTemplates.ensureSignedIn],
  action: function() {
    ReactLayout.render(Mypage, {myprops: myprops.value});
  }
});

似乎这一切都发生在triggersEnter: [...]关键。

更多细节在这里

于 2017-06-08T11:29:32.550 回答