2016-09-07 20 views
0

ですし、私はこのような条件を探していた場合:FlowRouterは、ユーザーがログインしている場合はリダイレクトとパスが、私はFlowRouterで流星を使用してい

私の現在のルートにリダイレクト:

Accounts.onLogin(function(){ 
     FlowRouter.go('clients'); 
    }); 
    Accounts.onLogout(function(){ 
     FlowRouter.go('home') 
    }); 

    FlowRouter.triggers.enter([function(context, redirect){ 
     if(!Meteor.userId()){ 
      FlowRouter.go('home') 
     } 
    }]); 


    FlowRouter.route('/', { 
     name: 'home', 
     action(){ 
      BlazeLayout.render('HomeLayout'); 
     } 
    }); 
    FlowRouter.route('/clients',{ 
     name: 'clients', 
     action(){ 
      BlazeLayout.render('MainLayout', {main: 'Clients'}); 
     } 
    }); 

答えて

0
if(Meteor.userId() && FlowRouter.getRouteName() === 'route_name'){ 
    FlowRouter.go('/route_name'); 
} 

フロールーターのドキュメントでは、上記のステートメントを再構成する必要がある場合は、現在のルートを取得することがいくつかありました。私はあなたは自分のFlowRouter.routeを変更する必要があると言うだろう https://github.com/kadirahq/flow-router/blob/master/README.md

0

(「/」...)コンフィギュレーションビット:

FlowRouter.route('/', { 
    triggersEnter: [function(context, redirect) { 
    if (Meteor.userId()) { 
     redirect('/clients'); 
    } 
    }], 
    name: 'home', 
    action(){ 
    BlazeLayout.render('HomeLayout'); 
    } 
}); 

ので、いずれかが「/」にアクセスし、そのユーザーにログインしますクライアントにリダイレクトされる - 私はそれをテストしたときにうまくいった。フロールータのドキュメントの背景情報は次のとおりです。https://github.com/kadirahq/flow-router/blob/master/README.md#redirecting-with-triggers

関連する問題