124. Generating Guard (#15 Section 17: Guard)

This commit is contained in:
Art
2021-09-16 19:52:23 +03:00
parent f775040738
commit 5d0eae9a3c
2 changed files with 31 additions and 0 deletions

View File

@ -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();
});
});

View File

@ -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<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return true;
}
}