fix user permissions

This commit is contained in:
Jonathan Baecker 2024-10-24 13:12:56 +02:00
parent 3cf0d12200
commit 532c4b4615
5 changed files with 13 additions and 8 deletions

View File

@ -467,8 +467,7 @@ async fn get_all_channels(
/// ``` /// ```
#[patch("/channel/{id}")] #[patch("/channel/{id}")]
#[protect( #[protect(
"Role::GlobalAdmin", any("Role::GlobalAdmin", "Role::ChannelAdmin"),
"Role::ChannelAdmin",
ty = "Role", ty = "Role",
expr = "user.channels.contains(&*id) || role.has_authority(&Role::GlobalAdmin)" expr = "user.channels.contains(&*id) || role.has_authority(&Role::GlobalAdmin)"
)] )]

View File

@ -15,8 +15,9 @@
v-model="channel.name" v-model="channel.name"
type="text" type="text"
placeholder="Type here" placeholder="Type here"
class="input input-bordered w-full" class="input input-bordered w-full !bg-base-100"
@keyup="isChanged" @keyup="isChanged"
:disabled="authStore.role === 'User'"
/> />
</label> </label>
@ -27,8 +28,9 @@
<input <input
v-model="channel.preview_url" v-model="channel.preview_url"
type="text" type="text"
class="input input-bordered w-full" class="input input-bordered w-full !bg-base-100"
@keyup="isChanged" @keyup="isChanged"
:disabled="authStore.role === 'User'"
/> />
</label> </label>
@ -39,8 +41,10 @@
<input <input
v-model="channel.extra_extensions" v-model="channel.extra_extensions"
type="text" type="text"
class="input input-bordered w-full" class="input input-bordered w-full !bg-base-100"
:class="'input-disabled'"
@keyup="isChanged" @keyup="isChanged"
:disabled="authStore.role === 'User'"
/> />
</label> </label>
@ -88,7 +92,7 @@
</label> </label>
</template> </template>
<div class="my-4 flex gap-1"> <div v-if="authStore.role !== 'User'" class="my-4 flex gap-1">
<button class="btn" :class="saved ? 'btn-primary' : 'btn-error'" @click="addUpdateChannel()"> <button class="btn" :class="saved ? 'btn-primary' : 'btn-error'" @click="addUpdateChannel()">
{{ t('config.save') }} {{ t('config.save') }}
</button> </button>

View File

@ -149,7 +149,9 @@ const user = ref({
} as User) } as User)
onMounted(() => { onMounted(() => {
getUsers() if (authStore.role === 'GlobalAdmin') {
getUsers()
}
}) })
async function getUsers() { async function getUsers() {

View File

@ -17,6 +17,7 @@
Advanced Advanced
</button> </button>
<button <button
v-if="authStore.role !== 'User'"
class="join-item btn btn-sm btn-primary mt-1 duration-500" class="join-item btn btn-sm btn-primary mt-1 duration-500"
:class="activeConf === 3 && 'btn-secondary'" :class="activeConf === 3 && 'btn-secondary'"
@click="activeConf = 3" @click="activeConf = 3"

View File

@ -19,7 +19,6 @@
{{ t('button.logging') }} {{ t('button.logging') }}
</NuxtLink> </NuxtLink>
<NuxtLink <NuxtLink
v-if="authStore.role.toLowerCase().includes('admin')"
:to="localePath({ name: 'configure' })" :to="localePath({ name: 'configure' })"
class="btn join-item btn-primary px-2" class="btn join-item btn-primary px-2"
> >