Login check level ($urlRouterProvider ?)


Hi there,

I got a beautiful login system which writes the id, level, name picture of the user, who’s logged in, to the localStorage. But my app now opens standard on page ‘/pendingrequests’, this is perfect for a manager (level 2), a user (level 1) should open the page in ‘/calendar’… Is there a way to check which level is logged on and depending on that level open the app on that page?

I know after logging in it can be done by location.path, but when I open the app again, and a USER is still logged in, the app again opens in /pendingrequests

btw: ‘localStorage[0].level’ keeps the level stored of the user who’s logged in.

Can anyone help me by setting up the function to check if level is 1 or 2 and set the $urlRouterProvider depending on this value?




Hi, I think that “pendingrequests” is linked to a Controller, right ? So, why do you not control in this controller if the user has the “permission” to see it ? The first operation in this controller is to check the value of localStorage[0].level, and if the value is 1 you can use $state.go("/calendar").

I follow this way in one of my app where I need to check if the user is logged or not into the remote system.

No ?



Yes, this is possible and it works! But then you see the transition between the pages and a “< Back” button will be applied to the page.

So, is it possible to just start at that page instead of navigating to it after the check?


Hi and hmmm…

If I don’t wrong remember you can delete the navigation history:

Is this a possible solution ?