FlowRouter redirection

Hey everyone,

I can’t figure out what i’m doing wrong. Basically I want to redirect the user to /registration/:id if Meteor.user().profile.submitted is true.

FlowRouter.route('/registration', {
name: 'registration',
action() {
	var profile = Meteor.user().profile;

	if (profile.submitted)
		FlowRouter.go('/registration/' + profile.registration_id);
	BlazeLayout.render('MainLayout', {
		main: 'NewRegistration'

When I come from another page, it works. But when I refresh from /registration, it doesnt redirect me. I see the uri change to the route i want but suddenly comes back to /registration.

Would appreciate some help. Thanks

I’m thinking you will probably want to use a trigger.

I’m dealing with something similar. On most of my app’s routes, if theres no Meteor.user() they should be redirected to the home route.

After doing some research, I don’t think you want to rely on FlowRouter to handle redirects, and instead should put them on the template level.

Which means you would put your profile.submitted logic inside of the NewRegistration.onCreated() autorun block. To make it extendable im thinking you’d make a little auth library to import and then call it by Auth_profileSubmitted(Meteor.user().profile.submitted)

Trigger method worked, thanks.

1 Like