Created
August 9, 2018 17:54
-
-
Save sairamkrish/8d889f3478a4db0bc9ed9e8dfd748434 to your computer and use it in GitHub Desktop.
Keycloak - angular - example routing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { Routes, RouterModule, PreloadAllModules } from '@angular/router'; | |
import { AppAuthGuard } from './app.authguard'; | |
... | |
const appRoutes: Routes = [ | |
{ | |
path: 'some-path-only-super-user-can-access', | |
loadChildren: () => SomeModule , | |
canActivate: [AppAuthGuard], | |
data: { roles: ['SuperUser'] } | |
}, | |
{ | |
path: 'some-other-path', | |
loadChildren: () => SomeOtherModule , | |
canActivate: [AppAuthGuard], | |
data: { roles: ['SuperUser', 'NormalUser'] } | |
}, | |
... | |
]; | |
@NgModule({ | |
... | |
providers: [AppAuthGuard] | |
}) | |
export class AppRoutingModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment