我有许多应用程序的通用防护:
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;
}
}
但是this.route.snapshot.params.site
路线为空:"/signin/macro/561"
。
路线声明:
{ path: 'signin/:site/:token', loadChildren: 'src/app/auth/auth.module#AuthModule' },