source: bus-n-go-pavel-216049/bus-n-go-frontend/src/app/guards/auth-canmatch.guard.ts@ baf4cc4

Last change on this file since baf4cc4 was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 410 bytes
RevLine 
[baf4cc4]1import {CanActivateFn, Router} from '@angular/router';
2import {inject} from "@angular/core";
3import {AuthService} from "../services/auth/auth.service";
4
5export const authCanmatchGuard: CanActivateFn = (route, state) => {
6 let service = inject(AuthService);
7 let router = inject(Router)
8 if (service.isAuthenticated()) {
9 return true;
10 }
11 else {
12 router.navigate(['/login'])
13 return false;
14 }
15};
Note: See TracBrowser for help on using the repository browser.