Property "redirectTo" inheritance
See original GitHub issueHello!
Documentation states that when using ui.router, we don’t need to repeat permissions already specified on parents within child’s permission data.
However it does not mention whether “redirectTo” is also inherited.
I’ve just decided to give it a try to angular-permission and I specified “redirectTo” on the topmost state (which I should point is also an abstract state).
Even though I could confirm that indeed it checks for permissions defined on the parent, the redirection logic doesn’t seem to be inherited.
Is that intended? Or maybe I’m doing something wrong?
Here’s a snippet of my configuration:
.state("app", { url: "", templateUrl: "app/shell.html", abstract: true, data: { permissions: { only: "AUTHORIZED", redirectTo: { default: "login" } } } })
.state("dashboard", { parent: "app", url: "/dashboard", templateUrl: "app/dashboard.html" })
.state("something", { parent: "app", url: "/something", templateUrl: "app/something.html", data: { permissions: { only: "SPECIFIC_ONE" } } })
With that configuration, going to “dashboard” validates “AUTHORIZED” and redirects to “login” if invalid.
Going to “something” will validate “AUTHORIZED”, then will validate “SPECIFIC_ONE” but if invalid will just stop transition and will not redirect to login.
Appreciate any help.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top GitHub Comments
My 2 cents.
Looking at the code
Why don’t we check if permissionMap.redirectTo is undefined before setting it. That way parent redirect to will not changed until something in child decides to change. It seems when I set a redirectTo rule in parent state, it gets override with undefined when child does not set redirectTo. This would be the simplest way to trickle redirectTo (under the assumption the path is properly inherited). This would required parent state to have defined permission. (areSetStatePermissions)
Then again ng-route doesn’t seem to extend the permissions; I’m not too familiar with ngRoute to comment.
Included in release 5.0.0