import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {AuthService} from '../servicess/auth.service';


@Injectable()
export class GuestGuard implements CanActivate {


  constructor(
    public authService: AuthService,
    public router: Router,
  ) {
  }

  canActivate(route: ActivatedRouteSnapshot,
              state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
    if (this.authService.isLoggedIn()) {
      return false;
    } else {
      return true;
    }
  }
}
