Added groups - missing user management. Fixed several issues.
This commit is contained in:
@ -21,7 +21,7 @@ import { ApiKeyService } from '../../shared/services/api/api-key.service';
|
||||
})
|
||||
export class ImpersonationComponent implements OnInit {
|
||||
private readonly keyService = inject(ApiKeyService);
|
||||
|
||||
|
||||
impersonated: string | undefined;
|
||||
users: { id: string, name: string }[];
|
||||
|
||||
@ -46,15 +46,17 @@ export class ImpersonationComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
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)]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public isAdmin() {
|
||||
@ -66,6 +68,9 @@ export class ImpersonationComponent implements OnInit {
|
||||
}
|
||||
|
||||
public onChange(e: any) {
|
||||
if (!this.auth.isAdmin())
|
||||
return;
|
||||
|
||||
if (!e.value) {
|
||||
this.http.delete(environment.API_HOST + '/admin/impersonate', {
|
||||
headers: {
|
||||
@ -92,4 +97,4 @@ export class ImpersonationComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user