fix: settings encryption

This commit is contained in:
Julian Krauser 2025-05-08 08:13:08 +02:00
parent 16ccd0d35f
commit 025cd555e9

View file

@ -57,7 +57,7 @@ export default abstract class SettingHelper {
}
let processedValue = rawValue;
if (typeof settingType.type === "string" && settingType.type.includes("/crypt")) {
if (typeof settingType.type === "string" && settingType.type.includes("/crypt") && processedValue != "") {
processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue);
}
@ -76,7 +76,7 @@ export default abstract class SettingHelper {
* @param value The value to set
*/
public static async setSetting<K extends SettingString>(key: K, value: SettingValueMapping[K]): Promise<void> {
if (value === undefined || value === null) {
if (value === undefined || value === null || value == "") {
if (key != "mail.password") this.resetSetting(key);
return;
}
@ -93,7 +93,7 @@ export default abstract class SettingHelper {
newValue = CodingHelper.encrypt(APPLICATION_SECRET, stringValue);
}
this.settings[key] = stringValue;
this.settings[key] = newValue;
const [topic, settingKey] = key.split(".") as [SettingTopic, string];
await SettingCommandHandler.create({