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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user