All files / app/guards auth.guard.ts

100% Statements 8/8
100% Branches 4/4
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21          142x     48x 48x         58x 2x 2x   56x    
import {Injectable} from "@angular/core";
import {CanActivate, Router} from "@angular/router"; 
import { SessionService } from "../services/session.service";
 
@Injectable({providedIn: 'root'})
export class AuthGuard implements CanActivate {
 
  constructor( 
    private router: Router,
    private sessionService: SessionService,
  ) {
  }
 
  public canActivate(): boolean {
    if (!this.sessionService.isLogged) {
      this.router.navigate(['login']);
      return false;
    }
    return true;
  }
}