Improve exercise type validation and encryption in settings service: Enhance error handling for exercise type name checks in both create-bisaya-course-content and update-week1-bisaya-exercises scripts. Implement encryption for API keys and user settings in settingsService, ensuring sensitive data is securely stored. Update localization files to include new terms related to model patterns in English, German, and Spanish.

This commit is contained in:
Torsten Schulz (local)
2026-03-25 16:09:04 +01:00
parent d50d3c4016
commit 6be816fe48
7 changed files with 82 additions and 51 deletions

View File

@@ -48,16 +48,21 @@ async function resolveExerciseTypeId(exercise) {
return exercise.exerciseTypeId;
}
const name = exercise.exerciseTypeName;
if (name === undefined || name === null || String(name).trim() === '') {
throw new Error(`Kein exerciseTypeId oder exerciseTypeName für Übung "${exercise.title || 'unbenannt'}"`);
}
const [type] = await sequelize.query(
`SELECT id FROM community.vocab_grammar_exercise_type WHERE name = :name LIMIT 1`,
{
replacements: { name: exercise.exerciseTypeName },
replacements: { name: String(name).trim() },
type: sequelize.QueryTypes.SELECT
}
);
if (!type) {
throw new Error(`Übungstyp "${exercise.exerciseTypeName}" nicht gefunden`);
throw new Error(`Übungstyp "${String(name).trim()}" nicht gefunden`);
}
return Number(type.id);