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

Last change on this file 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: 402 bytes
Line 
1import {CanActivateFn, Router} from '@angular/router';
2import {AuthService} from "../services/auth/auth.service";
3import {inject} from "@angular/core";
4
5export const authGuard: 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.