openaire-library/connect/communityGuard/isCommunity.guard.ts

21 lines
715 B
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
import {ActivatedRoute, Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/filter';
@Injectable()
export class IsCommunity implements CanActivate {
constructor(private route: ActivatedRoute,private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
let community = (route.queryParams["communityId"]);
if(community && community!="undefined"){
return true;
}else{
this.router.navigate(['errorcommunity']);
}
return false;
}
}