title: what is auth.guard.ts and AuthenticationService in angular 8?
body: <pre><code>import { Injectable } from '@angular/core';
  import { AuthenticationService } from './_services';
  import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
  
  
  @Injectable({ providedIn: 'root' })
  export class AuthGuard implements CanActivate {
      constructor(
          private router: Router,
          private authenticationService: AuthenticationService
      ) {}
  
      canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
          const currentUser = this.authenticationService.currentUserValue;
          if (currentUser) {
              // authorised so return true
              return true;
          }
  
          // not logged in so redirect to login page with the return url
          this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
          return false;
      }
  }
  </code></pre>