import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { AuthService } from './auth.service';

@Injectable()
export class LoginRedirect implements CanActivate {
  constructor(private auth: AuthService, private router: Router) {}
  canActivate(): boolean {
    if (localStorage.getItem('token')) {
      this.router.navigateByUrl('/dashboard');
      return false;
    }else if (localStorage.getItem('authToken')) {
      this.router.navigateByUrl('/employee');
      return false;
    }
    else {
      return true;
    }
  }
}
