-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Description
🚀 feature request
Relevant Package
This feature request is for @angular/routerDescription
Currently we have 2 levels of authorisation in our app: Super admin and Organisation Admin.
When those users login via /auth/login
the are authenticated and then the logic redirects to the root /
.
On the route path (''), I have 2 child routes, both using an UrlMatcher instead of a path.
{
path: '',
children: [
{
matcher: SuperAdminMatcher
loadChildren: <super admin module>
},
{
matcher: OrgAdminMatcher
loadChildren: <Org admin module>
}
]
Those matcher functions require to know what user was logged in via the AuthService. However, other then looking in my LocalStorage and get my JWT, there is no way for me to access the AuthService because I can't inject that service in the Matchers.
So my matcher can never reject based on AuthState.
I ideally want to offer to paths:
Superadmin:
/organisation/list
/organisation/ORG NAME/post/list
<- super admin opening an Organisation
Org admin:
/post/list
/post/edit/<guid>
So unfortunately I have to use to different path names to make this work, and that makes the path unnecessary long, like `http://localhost:4200/superadmin/organisation/Bramble-Cay-College/post/list
Describe the solution you'd like
If you have a solution in mind, please describe it.Allow for Injection of Providers in the Matcher. This way we can create a more advanced matcher. It is kinda like Resolve, however Resolve is currently happening after the Path or Url has been matched.
Describe alternatives you've considered
Have you considered any alternative solutions or workarounds?The only real workaround I can find is using different path names, or using a wrapper component.
However, I want each child to lazy load a Module, and I create a RootComponent, and load either the SuperAdminComponent or the OrgAdminComponent via *ngIf, it wouldn't be lazy loaded.