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. The logout
function was not included.
// 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');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.