fix backupSensitiveData
MODIFY
src/storage/mongodb/SettingStorage.ts
src/storage/mongodb/SettingStorage.ts
@@ -56,7 +56,7 @@ export default class SettingStorage {
identifier: settingToSave.identifier,
content: settingToSave.content,
sensitiveData: settingToSave.sensitiveData,
- backupSensitiveData: settingToSave.formerSensitiveData
+ backupSensitiveData: settingToSave.backupSensitiveData
};
DatabaseUtils.addLastChangedCreatedProps(settingMDB, settingToSave);
// Modify
@@ -83,7 +83,7 @@ export default class SettingStorage {
// ID
ocpiSettings.id = settings.result[0].id;
ocpiSettings.sensitiveData = settings.result[0].sensitiveData;
- ocpiSettings.formerSensitiveData = settings.result[0].formerSensitiveData;
+ ocpiSettings.backupSensitiveData = settings.result[0].backupSensitiveData;
// OCPI
if (config.ocpi) {
ocpiSettings.ocpi = config.ocpi;
@@ -104,7 +104,7 @@ export default class SettingStorage {
const config = settings.result[0].content;
analyticsSettings.id = settings.result[0].id;
analyticsSettings.sensitiveData = settings.result[0].sensitiveData;
- analyticsSettings.formerSensitiveData = settings.result[0].formerSensitiveData;
+ analyticsSettings.backupSensitiveData = settings.result[0].backupSensitiveData;
// SAP Analytics
if (config.sac) {
analyticsSettings.type = AnalyticsSettingsType.SAC;
@@ -129,7 +129,7 @@ export default class SettingStorage {
const config = settings.result[0].content;
assetSettings.id = settings.result[0].id;
assetSettings.sensitiveData = settings.result[0].sensitiveData;
- assetSettings.formerSensitiveData = settings.result[0].formerSensitiveData;
+ assetSettings.backupSensitiveData = settings.result[0].backupSensitiveData;
// Asset
if (config.asset) {
assetSettings.type = AssetSettingsType.ASSET;
@@ -152,7 +152,7 @@ export default class SettingStorage {
const config = settings.result[0].content;
refundSettings.id = settings.result[0].id;
refundSettings.sensitiveData = settings.result[0].sensitiveData;
- refundSettings.formerSensitiveData = settings.result[0].formerSensitiveData;
+ refundSettings.backupSensitiveData = settings.result[0].backupSensitiveData;
if (config.concur) {
refundSettings.type = RefundSettingsType.CONCUR;
refundSettings.concur = {
@@ -185,7 +185,7 @@ export default class SettingStorage {
// ID
pricingSettings.id = settings.result[0].id;
pricingSettings.sensitiveData = settings.result[0].sensitiveData;
- pricingSettings.formerSensitiveData = settings.result[0].formerSensitiveData;
+ pricingSettings.backupSensitiveData = settings.result[0].backupSensitiveData;
// Simple price
if (config.simple) {
pricingSettings.type = PricingSettingsType.SIMPLE;
@@ -223,7 +223,7 @@ export default class SettingStorage {
// ID
smartChargingSettings.id = settings.result[0].id;
smartChargingSettings.sensitiveData = settings.result[0].sensitiveData;
- smartChargingSettings.formerSensitiveData = settings.result[0].formerSensitiveData;
+ smartChargingSettings.backupSensitiveData = settings.result[0].backupSensitiveData;
// SAP Smart Charging
if (config.sapSmartCharging) {
smartChargingSettings.type = SmartChargingSettingsType.SAP_SMART_CHARGING;
@@ -258,7 +258,7 @@ export default class SettingStorage {
id: billingSettingsToSave.id,
identifier: billingSettingsToSave.identifier,
sensitiveData: billingSettingsToSave.sensitiveData,
- backupSensitiveData: billingSettingsToSave.formerSensitiveData,
+ backupSensitiveData: billingSettingsToSave.backupSensitiveData,
lastChangedOn: new Date(),
content: {
stripe: billingSettingsToSave.stripe
@@ -279,7 +279,7 @@ export default class SettingStorage {
const config = settings.result[0].content;
billingSettings.id = settings.result[0].id;
billingSettings.sensitiveData = settings.result[0].sensitiveData;
- billingSettings.formerSensitiveData = settings.result[0].formerSensitiveData;
+ billingSettings.backupSensitiveData = settings.result[0].backupSensitiveData;
// Currency
const pricingSettings = await SettingStorage.getPricingSettings(tenantID);
let currency = 'EUR';

MODIFY
src/utils/Cypher.ts
src/utils/Cypher.ts
@@ -188,11 +188,10 @@ export default class Cypher {
if (!Utils.isEmptyArray(settingsToMigrate)) {
// Migrate
for (const setting of settingsToMigrate) {
- if (!setting.formerSensitiveData && Utils.isEmptyArray(setting.formerSensitiveData)) {
+ if (!setting.backupSensitiveData && Utils.isEmptyArray(setting.backupSensitiveData)) {
// Save former senitive data in setting
const backupSensitiveData = Cypher.prepareFormerSenitiveData(setting);
- backupSensitiveData.push(Cypher.hash(cryptoSetting.formerKey));
- setting.formerSensitiveData =backupSensitiveData;
+ setting.backupSensitiveData = backupSensitiveData;
// Decrypt sensitive data with former key and key properties
await Cypher.decryptSensitiveDataInJSON(tenantID,setting, true);
// Encrypt sensitive data with new key and key properties
@@ -210,8 +209,8 @@ export default class Cypher {
if (!Utils.isEmptyArray(settingsToCleanup)) {
// Cleanup
for (const setting of settingsToCleanup) {
- if (setting.formerSensitiveData) {
- delete setting.formerSensitiveData;
+ if (setting.backupSensitiveData) {
+ delete setting.backupSensitiveData;
await SettingStorage.saveSettings(tenantID, setting);
}
}
@@ -253,7 +252,7 @@ export default class Cypher {
const value: string = _.get(setting, property);
// If the value is undefined, null or empty then do nothing and skip to the next property
if (value && value.length > 0) {
- backupSensitiveData.push(value);
+ backupSensitiveData[property] = value;
}
}
}

fix backupSensitiveData