casino/frontend/src/app/auth.guard.ts
2025-03-26 11:09:28 +01:00

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;
};