Refactor environment configuration for local development; update SMTP settings and add JWT secret, encryption key, and debug options. Enhance Nuxt configuration for development server and runtime settings. Introduce new membership application form with validation and PDF generation functionality. Update footer and navigation components to include new membership links. Revise user and session data in JSON files.
This commit is contained in:
72
server/api/membership/applications.get.js
Normal file
72
server/api/membership/applications.get.js
Normal file
@@ -0,0 +1,72 @@
|
||||
import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { decryptObject } from '../../utils/encryption.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const config = useRuntimeConfig()
|
||||
const encryptionKey = config.encryptionKey
|
||||
|
||||
if (!encryptionKey) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Verschlüsselungsschlüssel nicht konfiguriert'
|
||||
})
|
||||
}
|
||||
|
||||
const dataDir = path.join(process.cwd(), 'server/data/membership-applications')
|
||||
|
||||
// Prüfen ob Verzeichnis existiert
|
||||
try {
|
||||
await fs.access(dataDir)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
|
||||
// Alle Anträge laden
|
||||
const files = await fs.readdir(dataDir)
|
||||
const applications = []
|
||||
|
||||
for (const file of files) {
|
||||
if (file.endsWith('.json')) {
|
||||
try {
|
||||
const filePath = path.join(dataDir, file)
|
||||
const fileContent = await fs.readFile(filePath, 'utf8')
|
||||
const applicationData = JSON.parse(fileContent)
|
||||
|
||||
// Verschlüsselte Daten entschlüsseln
|
||||
const decryptedData = decryptObject(applicationData.encryptedData, encryptionKey)
|
||||
|
||||
applications.push({
|
||||
id: applicationData.id,
|
||||
timestamp: applicationData.timestamp,
|
||||
status: applicationData.status,
|
||||
metadata: applicationData.metadata,
|
||||
// Entschlüsselte persönliche Daten
|
||||
personalData: {
|
||||
nachname: decryptedData.nachname,
|
||||
vorname: decryptedData.vorname,
|
||||
email: decryptedData.email,
|
||||
telefon_privat: decryptedData.telefon_privat,
|
||||
telefon_mobil: decryptedData.telefon_mobil
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(`Fehler beim Laden von ${file}:`, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nach Zeitstempel sortieren (neueste zuerst)
|
||||
applications.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
|
||||
|
||||
return applications
|
||||
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Mitgliedschaftsanträge:', error)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Fehler beim Laden der Anträge'
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user