Added groups - missing user management. Fixed several issues.

This commit is contained in:
Tom
2025-03-18 12:55:00 +00:00
parent 2f88840ef6
commit 74b282ccfd
77 changed files with 1771 additions and 377 deletions

View File

@ -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 {
});
}
}
}
}