How to get the next route with the navController?


#1

How can I get access to the next route i’m going to with the navController?

I have a BasePage class which all my pages extends from. I use the ionViewCanEnter() method on my BasePage so I can validate wether the user can or cannot access that page. I use this code this.nav.getActive().name inside that method to get the page but this gives me the current page which i’m leaving.

I would like to get the next page where I want to go to be able to validate.

Any ideas on this? Thanks!


#2

This entire design sounds crazy to me, but one thing I can say with confidence is that relying on page names in code is going to fail in production, due to minification.


#3

Instead of bashing on what i am trying to achieve and not provide any alternative you could at least explain how you would do it instead… this forum is meant to help each other… if you don’t provide any alternative, don’t even bother answering posts.


#4

I would change the UI so that users have no way of reaching pages they are not supposed to reach (disable/eliminate menu items, for example). If this is truly a security issue, like something bad would happen if a user accesses an unauthorized page, then I would do all of the serious authorization logic inside the backend, because anybody could simply use any user agent to access any given endpoint.


#5

@skoff I think what @rapropos means, is this looks like a fairly unefficient navigation pattern. Usually, you know if a user has the rights to access this or that page BEFORE you actually load it (aka, in the constructor, or by means of a provider).
Because a check at every step will be a pain and a slowdown in your app.