add mail type and validation
This commit is contained in:
parent
2e3d0a755c
commit
ce9f621b8b
11 changed files with 193 additions and 19 deletions
|
@ -5,6 +5,7 @@ import SettingService from "../service/management/settingService";
|
|||
import { APPLICATION_SECRET } from "../env.defaults";
|
||||
import {
|
||||
BooleanConverter,
|
||||
EmailConverter,
|
||||
LongStringConverter,
|
||||
MsConverter,
|
||||
NumberConverter,
|
||||
|
@ -27,6 +28,7 @@ export default abstract class SettingHelper {
|
|||
number: new NumberConverter(),
|
||||
boolean: new BooleanConverter(),
|
||||
ms: new MsConverter(),
|
||||
email: new EmailConverter(),
|
||||
};
|
||||
|
||||
public static getAllSettings() {
|
||||
|
@ -79,7 +81,7 @@ export default abstract class SettingHelper {
|
|||
finalValue = CodingHelper.encrypt(APPLICATION_SECRET, stringValue);
|
||||
}
|
||||
|
||||
this.settings[key] = finalValue;
|
||||
this.settings[key] = stringValue;
|
||||
const [topic, settingKey] = key.split(".") as [SettingTopic, string];
|
||||
|
||||
await SettingCommandHandler.create({
|
||||
|
@ -144,13 +146,14 @@ export default abstract class SettingHelper {
|
|||
}
|
||||
|
||||
let processedValue = valueToCheck;
|
||||
if (typeof settingType.type === "string" && settingType.type.includes("/crypt")) {
|
||||
try {
|
||||
processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue);
|
||||
} catch (error) {
|
||||
throw new Error(`Unable to decrypt value for ${key}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
// do not encypt data here - data is only crypted towards database
|
||||
// if (typeof settingType.type === "string" && settingType.type.includes("/crypt")) {
|
||||
// try {
|
||||
// processedValue = CodingHelper.decrypt(APPLICATION_SECRET, processedValue);
|
||||
// } catch (error) {
|
||||
// throw new Error(`Unable to decrypt value for ${key}: ${error.message}`);
|
||||
// }
|
||||
// }
|
||||
|
||||
const baseType =
|
||||
typeof settingType.type === "string"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue