first
This commit is contained in:
commit
3b669918d0
59 changed files with 16928 additions and 0 deletions
17
frontend/src/app/auth.guard.ts
Normal file
17
frontend/src/app/auth.guard.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
import { CanActivateFn } from '@angular/router';
|
||||
import { inject } from '@angular/core';
|
||||
import {KeycloakService} from "keycloak-angular";
|
||||
|
||||
export const authGuard: CanActivateFn = async (route, state) => {
|
||||
const keycloakService = inject(KeycloakService);
|
||||
|
||||
const isLoggedIn = keycloakService.isLoggedIn();
|
||||
|
||||
if (isLoggedIn) {
|
||||
return true;
|
||||
} else {
|
||||
keycloakService.login();
|
||||
return false;
|
||||
}
|
||||
};
|
Reference in a new issue