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:
@@ -1,4 +1,4 @@
|
||||
import { verifyToken, getUserById } from '../utils/auth.js'
|
||||
import { verifyToken, getUserById, hasAnyRole } from '../utils/auth.js'
|
||||
import { saveMember } from '../utils/members.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
@@ -40,7 +40,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
// Only admin and vorstand can add/edit members
|
||||
if (user.role !== 'admin' && user.role !== 'vorstand') {
|
||||
if (!hasAnyRole(user, 'admin', 'vorstand')) {
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
message: 'Keine Berechtigung zum Hinzufügen/Bearbeiten von Mitgliedern. Erforderlich: admin oder vorstand Rolle.'
|
||||
@@ -48,7 +48,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
const body = await readBody(event)
|
||||
const { id, firstName, lastName, geburtsdatum, email, phone, address, notes } = body
|
||||
const { id, firstName, lastName, geburtsdatum, email, phone, address, notes, isMannschaftsspieler } = body
|
||||
|
||||
if (!firstName || !lastName) {
|
||||
throw createError({
|
||||
@@ -73,7 +73,8 @@ export default defineEventHandler(async (event) => {
|
||||
email: email || '',
|
||||
phone: phone || '',
|
||||
address: address || '',
|
||||
notes: notes || ''
|
||||
notes: notes || '',
|
||||
isMannschaftsspieler: isMannschaftsspieler === true || isMannschaftsspieler === 'true'
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user