meteormeteor-reactmeteor-useraccounts

Meteor React: What is the simplest way to ensure a user is logged in before rendergin a page?


Situation:

Problem:

I don't know what should be the proper syntax to secure a specific page as described in the useraccounts guide but with react.

Lets suppose that I want to secure <Mypage /> imported from './mypage.jsx'

How can I call {{> ensureSignedIn template="myTemplate"}} and reaplace "myTemplate" by <Mypage /> ?

I tried <Blaze template="atForm" template={Mypage} /> without success...

Is it even possible to make something like this ?


Solution

  • I found a solution:

    With kadira:flow-router Meteor's package, using react-layout and useraccounts:flow-routing, I can do something like that:

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

    It seems that it all happens into triggersEnter: [...] key.

    More details here.