How do I setup a redirect for signing out?


#1

I’m using meteor-useraccounts/iron-routing to manage users, I want to be able to take the user to a different page when they sign out but it doesn’t provide sign out routes. What can I do redirect the user when they sign out?


#2

Its not exactly what you are looking for, but i used FlowRouter, instead of iron routing…

Here you can do it like this:

if (Meteor.isClient) {

    Accounts.onLogin(function () {
        FlowRouter.go('loggeeeedINPAGE');
    });

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

#3

Thank you, I’m thinking of switching to FlowRouter altogether.


#4

useraccounts has a logout hook option. For example:

AccountsTemplates.configure({
  ...
  onLogoutHook() {
    // Do something after logging out!
  }
  ...
});

You can wire up your redirect using this option.