Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect() and FlowRouter.go() do not update address bar when called within trigger #239

Closed
serkandurusoy opened this issue Jul 30, 2015 · 5 comments
Labels

Comments

@serkandurusoy
Copy link

I'm using a basic trigger to check the currently logged in user's role and if it does not pass, I redirect to another route:

function requireRoleAdmin(context,redirect) {
  if (Meteor.isClient){
    if ( !userHasRole('admin') ) {
      redirect('/');
    }
  }
}

FlowRouter.route('/', {
  name: 'home',
  action: function(params) {
    BlazeLayout.render('mainLayout', { main: "home", navbar: "topNav", sidenav: "sideNav" });
  }
});

FlowRouter.route('/adminonly', {
  name: 'adminOnly',
  triggersEnter: [requireRoleAdmin],
  action: function(params) {
    BlazeLayout.render('mainLayout', { main: "adminOnly", navbar: "topNav", sidenav: "sideNav" });
  }
});

When I enter http://localhost:3000/adminonly directly, I do get redirected to http://localhost:3000/ but if I click on links with <a href="/adminonly">Go to admin area</> although the home template gets rendered, the URL on the address bar remains unchanged as http://localhost:3000/adminonly.

The behavior is the same when I use FlowRouter.go('/') instead as well.

@arunoda
Copy link
Contributor

arunoda commented Jul 31, 2015

You should not check user permission on the router. Could you check there are any errors on the console? If so, just bring them here.

@serkandurusoy
Copy link
Author

serkandurusoy commented Jul 31, 2015 via email

@arunoda
Copy link
Contributor

arunoda commented Jul 31, 2015

Okay. I will have a look at this.
On 2015 ජූලි 31, සිකු at පෙ.ව. 8.55 Serkan Durusoy notifications@github.com
wrote:

I'm not checking permission on the router, I already do that on the
main layout and establish a user session.

There's no reactive dependency either, just a simple one time check of
an information that is altrady on the client.

Besides, there is no problem with direct entry, just clicks on links.

There is no error printed on the console.


Reply to this email directly or view it on GitHub
#239 (comment)
.

@arunoda arunoda closed this as completed in 4681005 Aug 1, 2015
@arunoda arunoda reopened this Aug 1, 2015
@arunoda
Copy link
Contributor

arunoda commented Aug 1, 2015

Hi,

I just fixed this issue.
Could you try with the new version: 2.0.1

@arunoda arunoda added the bug label Aug 1, 2015
@serkandurusoy
Copy link
Author

Yes, it now works as expected. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants