Added a scuffed redirect to prior page for impersonation. Fixed some conditions for websocket message checks.
This commit is contained in:
@ -25,7 +25,7 @@ export class ImpersonationComponent implements OnInit {
|
||||
impersonated: string | undefined;
|
||||
users: { id: string, name: string }[];
|
||||
|
||||
constructor(private hermes: HermesClientService, private auth: ApiAuthenticationService, private router: Router, private events: EventService, private http: HttpClient, @Inject(PLATFORM_ID) private platformId: Object) {
|
||||
constructor(private client: HermesClientService, private auth: ApiAuthenticationService, private router: Router, private events: EventService, private http: HttpClient, @Inject(PLATFORM_ID) private platformId: Object) {
|
||||
this.users = []
|
||||
}
|
||||
|
||||
@ -46,17 +46,19 @@ export class ImpersonationComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
if (this.auth.isAdmin()) {
|
||||
this.events.listen('impersonation', (userId) => {
|
||||
this.keyService.fetch(true)
|
||||
.pipe(timeout(3000), first())
|
||||
.subscribe(async (d: ApiKey[]) => {
|
||||
if (d.length > 0)
|
||||
this.hermes.login(d[0].id);
|
||||
await this.router.navigate([this.router.url.substring(1)]);
|
||||
});
|
||||
});
|
||||
}
|
||||
this.events.listen('impersonation', (userId) => {
|
||||
const url = this.router.url;
|
||||
this.client.first(d => d.op == 2 && !d.d.another_client)
|
||||
.subscribe(async _ =>
|
||||
await setTimeout(async () =>
|
||||
await this.router.navigate([url.substring(1)]), 500));
|
||||
this.keyService.fetch(true)
|
||||
.pipe(timeout(3000), first())
|
||||
.subscribe(async (d: ApiKey[]) => {
|
||||
if (d.length > 0)
|
||||
this.client.login(d[0].id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public isAdmin() {
|
||||
@ -80,7 +82,7 @@ export class ImpersonationComponent implements OnInit {
|
||||
impersonation: e.value
|
||||
}
|
||||
}).subscribe(async (data: any) => {
|
||||
this.hermes.disconnect();
|
||||
this.client.disconnect();
|
||||
this.events.emit('impersonation', e.value);
|
||||
});
|
||||
} else {
|
||||
@ -91,7 +93,7 @@ export class ImpersonationComponent implements OnInit {
|
||||
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
|
||||
}
|
||||
}).subscribe(async (data: any) => {
|
||||
this.hermes.disconnect();
|
||||
this.client.disconnect();
|
||||
this.events.emit('impersonation', e.value);
|
||||
await this.router.navigate(['tts-login']);
|
||||
});
|
||||
|
Reference in New Issue
Block a user