remove keycloak
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, HostListener } from '@angular/core';
|
||||
import { ActivatedRoute, NavigationEnd, Router, RouterOutlet } from '@angular/router';
|
||||
import { KeycloakEventType, KeycloakService } from 'keycloak-angular';
|
||||
|
||||
import { filter } from 'rxjs/operators';
|
||||
import build from '../build';
|
||||
@@ -34,7 +33,6 @@ export class AppComponent {
|
||||
public loadingService: LoadingService,
|
||||
private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private keycloakService: KeycloakService,
|
||||
private userService: UserService,
|
||||
private confirmationService: ConfirmationService,
|
||||
private auditService: AuditService,
|
||||
@@ -50,35 +48,33 @@ export class AppComponent {
|
||||
});
|
||||
}
|
||||
ngOnInit() {
|
||||
// Überwache Keycloak-Events, um den Token-Refresh zu kontrollieren
|
||||
this.keycloakService.keycloakEvents$.subscribe({
|
||||
next: event => {
|
||||
if (event.type === KeycloakEventType.OnTokenExpired) {
|
||||
// Wenn der Token abgelaufen ist, versuchen wir einen Refresh
|
||||
this.handleTokenExpiration();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
private async handleTokenExpiration(): Promise<void> {
|
||||
try {
|
||||
// Versuche, den Token zu erneuern
|
||||
const refreshed = await this.keycloakService.updateToken();
|
||||
if (!refreshed) {
|
||||
// Wenn der Token nicht erneuert werden kann, leite zur Login-Seite weiter
|
||||
this.keycloakService.login({
|
||||
redirectUri: window.location.href, // oder eine andere Seite
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.error === 'invalid_grant' && error.error_description === 'Token is not active') {
|
||||
// Hier wird der Fehler "invalid_grant" abgefangen
|
||||
this.keycloakService.login({
|
||||
redirectUri: window.location.href,
|
||||
});
|
||||
}
|
||||
}
|
||||
// this.keycloakService.keycloakEvents$.subscribe({
|
||||
// next: event => {
|
||||
// if (event.type === KeycloakEventType.OnTokenExpired) {
|
||||
// this.handleTokenExpiration();
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
}
|
||||
// private async handleTokenExpiration(): Promise<void> {
|
||||
// try {
|
||||
// // Versuche, den Token zu erneuern
|
||||
// const refreshed = await this.keycloakService.updateToken();
|
||||
// if (!refreshed) {
|
||||
// // Wenn der Token nicht erneuert werden kann, leite zur Login-Seite weiter
|
||||
// this.keycloakService.login({
|
||||
// redirectUri: window.location.href, // oder eine andere Seite
|
||||
// });
|
||||
// }
|
||||
// } catch (error) {
|
||||
// if (error.error === 'invalid_grant' && error.error_description === 'Token is not active') {
|
||||
// // Hier wird der Fehler "invalid_grant" abgefangen
|
||||
// this.keycloakService.login({
|
||||
// redirectUri: window.location.href,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@HostListener('window:keydown', ['$event'])
|
||||
handleKeyboardEvent(event: KeyboardEvent) {
|
||||
if (event.shiftKey && event.ctrlKey && event.key === 'V') {
|
||||
|
||||
Reference in New Issue
Block a user