Logout link for flow router and meteor-useraccounts/core

Meteor-useraccounts core has been a great plugin and I’m currently using their atNavButton for login/logout. Unfortunately my needs have changed and i no longer need a login button so I would like to create a simple link in the navbar to logout.

I’ve been trying to find a guide online that explains how to use AccountsTemplates.logout() with flow router however I haven’t been able to find anything to date. I’ve looked at the docs however it assumes I have more knowldege than I actually have. I was hoping someone could post a simple solution to help me out or point me to something I may have missed.
Thanks

Hi @bp123, I think you’re simply looking for Meteor.logout(). Create an event for your template that fires when you click your custom navbar logout link, and inside of that call Meteor.logout(); I misread the link you posted initially. In order to use AccountsTemplates.logout(), you’ll want to place it inside a template event. Look up “Blaze events” for more detail on how to use them. In your specific case, you’ll want to create a “click” event for the custom link that you add to the navbar, and call AccountsTemplates.logout() inside of that event.

what alexpete said. here’s some code:

Header.html

<li><a href="#" class="logout"><i class="fa fa-sign-out"></i></a></li>

Header.js

Template.Header.events({
	'click .logout': function(event){
		event.preventDefault();
		AccountsTemplates.logout();
	}
});

Thanks guys. That worked perfectly. Thanks again!