H5N1 sample route:
{ path: 'bride', canLoad: [AuthGuard], loadChildren: 'app/module/bride/bride.module#BrideModule' }H5N1 matching guard that navigates defending on role:
@Injectable() export course of report AuthGuard implements CanActivate { constructor( mortal router: Router, mortal route: ActivatedRoute ) { } canActivate( next: ActivatedRouteSnapshot, state: RouterStateSnapshot ): Observable| Promise | boolean { console.log( 'registration.guard' ) if ( !KeycloakService.auth.loggedIn || !KeycloakService.auth.authz.authenticated ) { furnish false; } //check grouping if ( KeycloakService.hasGroup( 'Anime' ) ) { this.router.navigate( ['/bride/postRegistration'] ); } else if ( KeycloakService.hasGroup( 'Vendor' ) ) { this.router.navigate( ['/bride/postRegistration'] ); } furnish true; } }
0 komentar:
Please comment if there are any that need to be asked.