简体   繁体   English

Meteor.js注销路由不会重定向

[英]Meteor.js logout route won't redirect

I'm am trying to make my router redirect to my home route upon logout but meteor continually returns me to the meteor generated login form instead. 我正在尝试使路由器在注销后重定向到我的本地路由,但是流星不断将我返回到流星生成的登录表单。 Am I doing something incorrectly? 我做错了什么吗?

This is my router: 这是我的路由器:

Router.route('/', {
  name: 'home'
});

Router.route('/logout', function(){
  var self = this;
  Meteor.logout(function(err){
      if(err){
        console.log('Error Logging out: '+ err);
      }
    self.redirect('/');
    // Router.go('home'); (Also tried this and didn't work)
  });
}); 

Figured it out ... painfully obvious. 想通了...很明显。

I've an ensureSignedIn function that checks the logged in status and redirects to the login form. 我有一个ensureSignedIn函数,用于检查登录状态并重定向到登录表单。 The logout function was not included. 不包括logout功能。

// LOGGED IN
Router.plugin('ensureSignedIn', {
  except: ['home','logout']
});

I am also newbie in meteor. 我也是流星的新手。 But the below code is works fine in my app. 但是下面的代码在我的应用程序中可以正常工作。 Hope it may help you a bit. 希望它可以对您有所帮助。

Router.route('home', {
  path: '/'
});
// After logout redirect by
Router.go('home');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM