Ui router authenticated routes

Hello,

I have recently changed my app structure and since then noticed that resolve is not firing from abstract routes on navigating history back… So on my abstract route I have:

resolve: {
  currentUser($q) {
    if (Meteor.userId() === null) {
      return $q.reject('AUTH_REQUIRED');
    } else {
      return $q.resolve();
    }
  }
}

And it works, but if user signs out, its being redirected to home url and then by clicking history back ui router resolve wouldnt run and user would be able to navigate back to authenticated route without being logged in. On browser refresh this wouldnt happen… Any thoughts would be very appreciated! If anyone have a better idea of authenticating it would be awesome!

Cheers

Ok I got it guys, the problem is that I’m using ui-router-extras for sticky states and they are being injected into my route, that messes up history navigation, if I remove injection and move it to its children all is solved.

1 Like