Enhance authentication checks in CMS API endpoints; implement user role validation for admin and board access. Refactor Spielpläne API to remove unnecessary logging and improve error handling. Update tests to mock user authentication and ensure proper validation of file uploads.

This commit is contained in:
Torsten Schulz (local)
2025-11-10 13:18:29 +01:00
parent bde1d32b14
commit 3d6646cf31
5 changed files with 81 additions and 18 deletions

View File

@@ -4,21 +4,16 @@ import path from 'path'
export default defineEventHandler(async (event) => {
try {
const spielplaeneDir = path.join(process.cwd(), 'public', 'spielplaene')
console.log('=== SPIELPLÄNE API ===')
console.log('Verzeichnis:', spielplaeneDir)
// Prüfe, ob das Verzeichnis existiert
try {
await fs.access(spielplaeneDir)
} catch {
console.log('Verzeichnis nicht gefunden')
return []
}
// Lese alle Dateien im Verzeichnis
const dateien = await fs.readdir(spielplaeneDir)
console.log('Alle Dateien:', dateien)
// Filtere nur relevante Dateitypen
const erlaubteExtensions = ['.pdf', '.xlsx', '.xls', '.doc', '.docx']
@@ -26,10 +21,7 @@ export default defineEventHandler(async (event) => {
const ext = path.extname(datei).toLowerCase()
return erlaubteExtensions.includes(ext)
})
console.log('Gefilterte Dateien:', gefiltert)
console.log('Anzahl:', gefiltert.length)
return gefiltert
} catch (error) {
console.error('Fehler beim Lesen der Spielpläne:', error)