Update role-based access control for user management in CMS

This commit modifies the navigation and CMS user management components to allow access for both 'admin' and 'vorstand' roles. The changes include updating the conditional rendering logic in the Navigation and index.vue files, as well as adjusting the API endpoint to reflect the new role permissions, enhancing the flexibility of user access within the CMS.
This commit is contained in:
Torsten Schulz (local)
2026-02-06 10:35:13 +01:00
parent 57b32debeb
commit 2d974214ab
3 changed files with 5 additions and 3 deletions

View File

@@ -850,6 +850,7 @@
Mitgliedschaftsanträge Mitgliedschaftsanträge
</NuxtLink> </NuxtLink>
<NuxtLink <NuxtLink
v-if="getAuthStore()?.hasAnyRole('admin', 'vorstand')"
to="/cms/benutzer" to="/cms/benutzer"
class="block px-4 py-2 text-sm text-yellow-300 hover:text-white hover:bg-primary-700/50 rounded-lg transition-colors" class="block px-4 py-2 text-sm text-yellow-300 hover:text-white hover:bg-primary-700/50 rounded-lg transition-colors"
@click="isMobileMenuOpen = false" @click="isMobileMenuOpen = false"

View File

@@ -225,9 +225,9 @@
</p> </p>
</NuxtLink> </NuxtLink>
<!-- Benutzerverwaltung (nur für Admin) --> <!-- Benutzerverwaltung (Admin ODER Vorstand) -->
<NuxtLink <NuxtLink
v-if="authStore.hasRole('admin')" v-if="authStore.hasAnyRole('admin', 'vorstand')"
to="/cms/benutzer" to="/cms/benutzer"
class="bg-white p-6 rounded-xl shadow-lg border border-gray-100 hover:shadow-xl transition-all group" class="bg-white p-6 rounded-xl shadow-lg border border-gray-100 hover:shadow-xl transition-all group"
> >

View File

@@ -5,7 +5,8 @@ export default defineEventHandler(async (event) => {
const token = getCookie(event, 'auth_token') const token = getCookie(event, 'auth_token')
const currentUser = await getUserFromToken(token) const currentUser = await getUserFromToken(token)
if (!currentUser || !hasAnyRole(currentUser, 'admin')) { // Seite darf von Admin ODER Vorstand genutzt werden
if (!currentUser || !hasAnyRole(currentUser, 'admin', 'vorstand')) {
throw createError({ throw createError({
statusCode: 403, statusCode: 403,
message: 'Zugriff verweigert' message: 'Zugriff verweigert'