This repository has been archived on 2025-02-19. You can view files and clone it, but cannot push or open issues or pull requests.
casino/frontend/src/app/auth.guard.ts
2025-02-12 11:00:29 +01:00

15 lines
381 B
TypeScript

import {CanActivateFn} from '@angular/router';
import {inject} from '@angular/core';
import {KeycloakService} from 'keycloak-angular';
export const authGuard: CanActivateFn = async () => {
const keycloakService = inject(KeycloakService);
const isLoggedIn = keycloakService.isLoggedIn();
if (isLoggedIn) {
return true;
}
keycloakService.login();
return false;
};