[SOLVED] Redirecting after login using FlowRouter


#1

I tried to do a redirect after a successful login. The redirectAfterLogin is set correctly and FlowRouter.go(redirect); will be executed. Bu instead of showing the right page the route will stuck on “/”.

Accounts.onLogin(function () {
    let redirect = Session.get("redirectAfterLogin");
    if(redirect) {
        Session.set("redirectAfterLogin", null);
        FlowRouter.go(redirect);
    } else {
        FlowRouter.go("/");
    }
});

#2

Meteor.setTimeout(function() {FlowRouter.go(redirect)}, 100); did the trick


#3

You can use Meteor.defer instead of Meteor.setTimeout