added a package guard
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
b7b168dffb
commit
39993e75da
19
projects/common/src/fm/services/package-guard.service.ts
Normal file
19
projects/common/src/fm/services/package-guard.service.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot} from '@angular/router';
|
||||||
|
import {PackageService} from './package.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class PackageGuardService implements CanActivate {
|
||||||
|
|
||||||
|
constructor(private packageService: PackageService) { }
|
||||||
|
|
||||||
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
|
||||||
|
return route.data && route.data.package && this.hasPackageForRoute(route.data.package);
|
||||||
|
}
|
||||||
|
|
||||||
|
private hasPackageForRoute(packageId: string): boolean {
|
||||||
|
return this.packageService.hasPackage(packageId);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user