Implement PDF download functionality for membership applications; enhance application data handling in the API to support both encrypted and unencrypted formats. Update UI to display download button conditionally based on PDF generation status.
This commit is contained in:
@@ -5,7 +5,7 @@ import { decryptObject } from '../../utils/encryption.js'
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const config = useRuntimeConfig()
|
||||
const encryptionKey = config.encryptionKey
|
||||
const encryptionKey = config.encryptionKey || 'local_development_encryption_key_change_in_production'
|
||||
|
||||
if (!encryptionKey) {
|
||||
throw createError({
|
||||
@@ -34,25 +34,35 @@ export default defineEventHandler(async (event) => {
|
||||
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
|
||||
}
|
||||
})
|
||||
// Prüfe ob Daten verschlüsselt oder unverschlüsselt sind
|
||||
if (applicationData.personalData) {
|
||||
// Unverschlüsselte Daten (neues Format)
|
||||
applications.push({
|
||||
id: applicationData.id,
|
||||
timestamp: applicationData.timestamp,
|
||||
status: applicationData.status,
|
||||
metadata: applicationData.metadata,
|
||||
personalData: applicationData.personalData
|
||||
})
|
||||
} else if (applicationData.encryptedData) {
|
||||
// Verschlüsselte Daten (altes Format)
|
||||
const decryptedData = decryptObject(applicationData.encryptedData, encryptionKey)
|
||||
applications.push({
|
||||
id: applicationData.id,
|
||||
timestamp: applicationData.timestamp,
|
||||
status: applicationData.status,
|
||||
metadata: applicationData.metadata,
|
||||
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)
|
||||
console.error(`Fehler beim Laden von ${file}:`, error.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user