Add login successful alert

This commit is contained in:
Phan Huy Tran 2025-02-12 11:37:45 +01:00
parent 9dd14cd944
commit 56fcb75599

View file

@ -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<boolean> {
return () => initializeKeycloak(keycloak)();