I have a lot of trusts in my website, so to make secure routes I build the next guard:
export class TrustGuard implements CanActivate {
constructor(private router: Router) {
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return /*Check if user has the trust or not*/;
}
}
So, in the routes I will can add the guard like canActivate: [TrustGuard]
The problem is that I have too many trusts, consequently I would need to build one guard for each trust. So I'm trying to build a factory of guards that to avoid to implements too many similar guards.
My target is to find the way of set the route like
canActivate: [FactoryTrustGuard(Trust.seeDashboard)]
Is it that possible?