From a701807831459deb3e12109cc56d48a1d336b84d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 6 Mar 2023 08:25:46 +0100 Subject: [PATCH] Fixed frontend permissions --- .../server/levels/components/levels/levels.component.html | 8 ++++---- .../server/levels/components/levels/levels.component.ts | 6 +++++- kdb-web/src/app/services/sidebar/sidebar.service.ts | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html index 22d5c663..0e5ed0ed 100644 --- a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html +++ b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.html @@ -185,14 +185,14 @@
+ (click)="onRowEditInit(dt, level, ri)" [disabled]="!user || user.isModerator && !user.isAdmin"> + (click)="deleteLevel(level)" [disabled]="!user || user.isModerator && !user.isAdmin"> + icon="pi pi-check-circle" (click)="onRowEditSave(dt, level, ri)" [disabled]="!user || user.isModerator && !user.isAdmin"> + icon="pi pi-times-circle" (click)="onRowEditCancel(ri)" [disabled]="!user || user.isModerator && !user.isAdmin">
diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts index cf83aaf5..d3a06f84 100644 --- a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts +++ b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts @@ -21,6 +21,7 @@ import { LevelMutationResult, UpdateUserMutationResult } from "../../../../../.. import { Mutations } from "../../../../../../models/graphql/mutations.model"; import { Subject, throwError } from "rxjs"; import { Server } from "../../../../../../models/data/server.model"; +import { UserDTO } from "../../../../../../models/auth/auth-user.dto"; @Component({ selector: "app-levels", @@ -58,6 +59,7 @@ export class LevelsComponent implements OnInit, OnDestroy { private unsubscriber = new Subject(); private server: Server = {}; + public user: UserDTO | null = null; public constructor( private authService: AuthService, @@ -73,9 +75,11 @@ export class LevelsComponent implements OnInit, OnDestroy { public ngOnInit(): void { this.setFilterForm(); - this.data.getServerFromRoute(this.route).then(server => { + this.data.getServerFromRoute(this.route).then(async server => { this.server = server; this.loadNextPage(); + let authUser = await this.authService.getLoggedInUser(); + this.user = authUser?.users?.find(u => u.server == this.server.id) ?? null; }); } diff --git a/kdb-web/src/app/services/sidebar/sidebar.service.ts b/kdb-web/src/app/services/sidebar/sidebar.service.ts index 925e6887..59304f35 100644 --- a/kdb-web/src/app/services/sidebar/sidebar.service.ts +++ b/kdb-web/src/app/services/sidebar/sidebar.service.ts @@ -140,8 +140,8 @@ export class SidebarService { if (this.server$.value) { this.serverMenu.visible = true; this.serverMembers.visible = !!user?.isModerator; - this.serverAutoRoles.visible = !!user?.isAdmin; - this.serverLevels.visible = !!user?.isAdmin; + this.serverAutoRoles.visible = !!user?.isModerator; + this.serverLevels.visible = !!user?.isModerator; } else { this.serverMenu.visible = false; }