From 532c4b4615593ed7dd0c5e92ff7b169a84ef4c41 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Thu, 24 Oct 2024 13:12:56 +0200 Subject: [PATCH] fix user permissions --- engine/src/api/routes.rs | 3 +-- frontend/components/ConfigChannel.vue | 12 ++++++++---- frontend/components/ConfigUser.vue | 4 +++- frontend/pages/configure.vue | 1 + frontend/pages/index.vue | 1 - 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/engine/src/api/routes.rs b/engine/src/api/routes.rs index 6dc31898..0f70b115 100644 --- a/engine/src/api/routes.rs +++ b/engine/src/api/routes.rs @@ -467,8 +467,7 @@ async fn get_all_channels( /// ``` #[patch("/channel/{id}")] #[protect( - "Role::GlobalAdmin", - "Role::ChannelAdmin", + any("Role::GlobalAdmin", "Role::ChannelAdmin"), ty = "Role", expr = "user.channels.contains(&*id) || role.has_authority(&Role::GlobalAdmin)" )] diff --git a/frontend/components/ConfigChannel.vue b/frontend/components/ConfigChannel.vue index ef806ae1..c8f9a93f 100644 --- a/frontend/components/ConfigChannel.vue +++ b/frontend/components/ConfigChannel.vue @@ -15,8 +15,9 @@ v-model="channel.name" type="text" placeholder="Type here" - class="input input-bordered w-full" + class="input input-bordered w-full !bg-base-100" @keyup="isChanged" + :disabled="authStore.role === 'User'" /> @@ -27,8 +28,9 @@ @@ -39,8 +41,10 @@ @@ -88,7 +92,7 @@ -
+
diff --git a/frontend/components/ConfigUser.vue b/frontend/components/ConfigUser.vue index dbbce716..8d902830 100644 --- a/frontend/components/ConfigUser.vue +++ b/frontend/components/ConfigUser.vue @@ -149,7 +149,9 @@ const user = ref({ } as User) onMounted(() => { - getUsers() + if (authStore.role === 'GlobalAdmin') { + getUsers() + } }) async function getUsers() { diff --git a/frontend/pages/configure.vue b/frontend/pages/configure.vue index 5c8f0c6c..09ede593 100644 --- a/frontend/pages/configure.vue +++ b/frontend/pages/configure.vue @@ -17,6 +17,7 @@ Advanced