Update dependencies to include TinyMCE and Quill, enhance Navigation component with a new Newsletter submenu, and implement role-based access control for CMS features. Refactor user role handling to support multiple roles and improve user management functionality across various API endpoints.

This commit is contained in:
Torsten Schulz (local)
2025-12-19 09:51:28 +01:00
parent baf6c59c0d
commit 435e28fd55
69 changed files with 5034 additions and 276 deletions

View File

@@ -4,12 +4,22 @@ export const useAuthStore = defineStore('auth', {
state: () => ({
isLoggedIn: false,
user: null,
role: null
roles: [],
role: null // Rückwärtskompatibilität: erste Rolle
}),
getters: {
isAdmin: (state) => {
return state.role === 'admin' || state.role === 'vorstand'
return state.roles.includes('admin') || state.roles.includes('vorstand')
},
isNewsletter: (state) => {
return state.roles.includes('newsletter')
},
hasRole: (state) => {
return (role) => state.roles.includes(role)
},
hasAnyRole: (state) => {
return (...roles) => roles.some(role => state.roles.includes(role))
}
},
@@ -19,11 +29,13 @@ export const useAuthStore = defineStore('auth', {
const response = await $fetch('/api/auth/status')
this.isLoggedIn = response.isLoggedIn
this.user = response.user
this.role = response.role
this.roles = response.roles || (response.role ? [response.role] : [])
this.role = response.role || (this.roles.length > 0 ? this.roles[0] : null) // Rückwärtskompatibilität
return response
} catch (error) {
this.isLoggedIn = false
this.user = null
this.roles = []
this.role = null
return { isLoggedIn: false }
}
@@ -47,6 +59,7 @@ export const useAuthStore = defineStore('auth', {
await $fetch('/api/auth/logout', { method: 'POST' })
this.isLoggedIn = false
this.user = null
this.roles = []
this.role = null
} catch (error) {
console.error('Logout fehlgeschlagen:', error)