16 lines
384 B
TypeScript
16 lines
384 B
TypeScript
import { CanActivateFn, Router } from '@angular/router';
|
|
import { inject } from '@angular/core';
|
|
import { AuthService } from './service/auth.service';
|
|
|
|
export const authGuard: CanActivateFn = async () => {
|
|
const authService = inject(AuthService);
|
|
const router = inject(Router);
|
|
|
|
if (authService.isLoggedIn()) {
|
|
return true;
|
|
}
|
|
|
|
router.navigate(['']);
|
|
|
|
return false;
|
|
};
|