Fixed issues with impersonation. Show warning or error depending on connection's remaining time before expiry. Replaced use of /api/... in urls.

This commit is contained in:
Tom
2025-04-05 02:06:31 +00:00
parent 70e0e9bf71
commit 3e9a9f9dc5
18 changed files with 129 additions and 71 deletions

View File

@ -60,9 +60,8 @@ export class ImpersonationComponent implements OnInit {
impersonation: impersonationId
}
}).subscribe(async (data: any) => {
this.impersonationControl.setValue(undefined);
this.client.disconnect(true);
this.events.emit('impersonation', undefined);
this.events.emit('impersonation', impersonationId);
});
} else {
this.http.put(environment.API_HOST + '/admin/impersonate', {
@ -72,7 +71,6 @@ export class ImpersonationComponent implements OnInit {
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
}
}).subscribe(async (data: any) => {
this.impersonationControl.setValue(impersonationId);
this.client.disconnect(true);
this.events.emit('impersonation', impersonationId);
await this.router.navigate(['tts-login']);

View File

@ -18,6 +18,7 @@
</mat-card-content>
<mat-card-actions>
<button mat-raised-button
[disabled]="disabled"
(click)="login()">Log In</button>
</mat-card-actions>
</mat-card>

View File

@ -32,13 +32,17 @@ export class TtsLoginComponent implements OnInit, OnDestroy {
keyControl = new FormControl<string | null>('');
api_keys: { id: string, label: string }[] = [];
subscriptions: (Subscription | null)[] = [];
disabled: boolean = false;
ngOnInit(): void {
this.route.data.subscribe(d => this.api_keys = d['keys']);
this.subscriptions.push(this.eventService.listen('impersonation', _ => this.reset()));
this.subscriptions.push(this.eventService.listen('logoff', _ => this.reset()));
this.subscriptions.push(this.eventService.listen('logoff', impersonation => {
if (!impersonation)
this.reset();
}));
}
ngOnDestroy(): void {
@ -57,7 +61,11 @@ export class TtsLoginComponent implements OnInit, OnDestroy {
}
private reset() {
this.disabled = true;
this.api_keys = [];
this.keyService.fetch().subscribe(keys => this.api_keys = keys);
this.keyService.fetch().subscribe(keys => {
this.api_keys = keys;
this.disabled = false;
});
}
}