import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { AuthService } from './auth.service';
import {LocalStorageService} from "angular-2-local-storage";

@Injectable()
export class AuthenticationService implements CanActivate {
  constructor(protected localStorageService: LocalStorageService, private auth: AuthService, private router: Router) {

    console.log(localStorage.getItem('testAuth'));
    console.log(this.localStorageService.get('testAuth'));
   // alert(this.localStorageService.get('userInfo'));
    //alert(localStorage.getItem('testAuth'));
  }
  canActivate(): boolean {

    var AuthSafe = this.localStorageService.get('userInfo')
    if (new RegExp('PGM').test(AuthSafe['roles'])) {
    //  this.router.navigateByUrl('/comingSoon');
      return true;
    }
    else {
      return false;
    }
  }
}
