openaire-library/error/isDevelopmentGuard.guard.ts

22 lines
675 B
TypeScript
Raw Normal View History

2022-10-10 15:56:13 +02:00
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot, UrlSegment, UrlTree} from '@angular/router';
import {Observable} from 'rxjs';
import {properties} from "../../../environments/environment";
@Injectable({
providedIn: 'root'
})
export class isDevelopmentGuard {
2022-10-10 15:56:13 +02:00
constructor(private router: Router) {
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree{
2022-10-10 15:56:13 +02:00
if(properties.environment == 'development') {
return true;
} else {
this.router.navigate([properties.errorLink]);
}
}
}