import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , CanActivate , Router , RouterStateSnapshot , UrlTree } from '@angular/router' ; import { Observable } from 'rxjs' ; import { AuthService } from "../services/auth.service" ; @ Injectable ( { providedIn : 'root' } ) export class NotAuthenticatedGuard implements CanActivate { constructor ( public auth , public router ) { } canActivate ( route , state ) { if ( this . auth . isAuthenticated ( ) ) { this . router . navigate ( [ '/' ] ) ; return false ; } return true ; } }