I have generic guard for many applications:
export class Guard implements CanActivate {
constructor(private authService: AuthService, private router: Router, private route: ActivatedRoute) {}
async canActivate(route: ActivatedRouteSnapshot) {
const user = await this.authService.getUserAuthenticated();
const hasPerm = user && user.hasPermission(route.data.app);
if (!hasPerm) {
this.router.navigate(['/login/' + this.route.snapshot.params.site, {}]);
}
return true;
}
}
But this.route.snapshot.params.site
is empty for route : "/signin/macro/561"
.
the route declaration :
{ path: 'signin/:site/:token', loadChildren: 'src/app/auth/auth.module#AuthModule' },