Angular2 routing canActivate and AuthGuard (JWT) with user role parameter
You can set the data parameter of the route with the role like this const appRoutes: Routes = [ { path: ‘account/super-secure’, component: SuperSecureComponent, canActivate: [RoleGuard], data: { roles: [‘super-admin’, ‘admin’] } }]; and then have this in canActivate of RoleGuard: canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { let roles = route.data[“roles”] as Array<string>; return (roles … Read more