From a6c38561352f194d2fd6900983d2901eb2e303ca Mon Sep 17 00:00:00 2001
From: Phan Huy Tran
Date: Wed, 12 Feb 2025 11:37:45 +0100
Subject: [PATCH] Add login successful alert
---
frontend/src/app/app.config.ts | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/frontend/src/app/app.config.ts b/frontend/src/app/app.config.ts
index e7761ba..fad1cf3 100644
--- a/frontend/src/app/app.config.ts
+++ b/frontend/src/app/app.config.ts
@@ -3,18 +3,26 @@ import {
ApplicationConfig,
provideExperimentalZonelessChangeDetection,
} from '@angular/core';
-import { provideRouter } from '@angular/router';
+import {provideRouter} from '@angular/router';
-import { routes } from './app.routes';
+import {routes} from './app.routes';
import {
KeycloakAngularModule,
- KeycloakBearerInterceptor,
+ KeycloakBearerInterceptor, KeycloakEventType,
KeycloakService,
} from 'keycloak-angular';
-import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
+import {HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi} from '@angular/common/http';
-export const initializeKeycloak = (keycloak: KeycloakService) => async () =>
- keycloak.init({
+export const initializeKeycloak = (keycloak: KeycloakService) => async () => {
+ keycloak.keycloakEvents$.subscribe({
+ next: (e: any) => {
+ if (e.type === KeycloakEventType.OnAuthSuccess) {
+ alert('Login erfolreich');
+ }
+ }
+ });
+
+ return await keycloak.init({
config: {
url: 'http://localhost:9090',
realm: 'LF12',
@@ -28,6 +36,7 @@ export const initializeKeycloak = (keycloak: KeycloakService) => async () =>
redirectUri: 'http://localhost:4200',
},
});
+}
function initializeApp(keycloak: KeycloakService): () => Promise {
return () => initializeKeycloak(keycloak)();