From 5d0eae9a3cd29446e89e9732e12dd3cf95d5fb79 Mon Sep 17 00:00:00 2001 From: Art Date: Thu, 16 Sep 2021 19:52:23 +0300 Subject: [PATCH] 124. Generating Guard (#15 Section 17: Guard) --- .../src/app/guard/authentication.guard.spec.ts | 16 ++++++++++++++++ .../src/app/guard/authentication.guard.ts | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 support-portal-frontend/src/app/guard/authentication.guard.spec.ts create mode 100644 support-portal-frontend/src/app/guard/authentication.guard.ts diff --git a/support-portal-frontend/src/app/guard/authentication.guard.spec.ts b/support-portal-frontend/src/app/guard/authentication.guard.spec.ts new file mode 100644 index 0000000..63b7a1c --- /dev/null +++ b/support-portal-frontend/src/app/guard/authentication.guard.spec.ts @@ -0,0 +1,16 @@ +import {TestBed} from '@angular/core/testing'; + +import {AuthenticationGuard} from './authentication.guard'; + +describe('AuthenticationGuard', () => { + let guard: AuthenticationGuard; + + beforeEach(() => { + TestBed.configureTestingModule({}); + guard = TestBed.inject(AuthenticationGuard); + }); + + it('should be created', () => { + expect(guard).toBeTruthy(); + }); +}); diff --git a/support-portal-frontend/src/app/guard/authentication.guard.ts b/support-portal-frontend/src/app/guard/authentication.guard.ts new file mode 100644 index 0000000..89117e1 --- /dev/null +++ b/support-portal-frontend/src/app/guard/authentication.guard.ts @@ -0,0 +1,15 @@ +import {Injectable} from '@angular/core'; +import {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree} from '@angular/router'; +import {Observable} from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class AuthenticationGuard implements CanActivate { + canActivate( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { + return true; + } + +}