Protetto le password (al load) che vengono settate in settings
This commit is contained in:
@@ -39,6 +39,10 @@ const SettingsSchema = new Schema({
|
||||
serv: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
crypted: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
@@ -63,6 +67,8 @@ SettingsSchema.statics.getValDbSettings = function (idapp, key, def) {
|
||||
return myrec.value_num;
|
||||
else if (myrec.type === tools.FieldType.boolean)
|
||||
return myrec.value_bool;
|
||||
else if (myrec.type === tools.FieldType.crypted)
|
||||
return tools.decryptdata(myrec.value_str);
|
||||
else
|
||||
return myrec.value_str;
|
||||
} else {
|
||||
@@ -82,18 +88,35 @@ SettingsSchema.statics.DuplicateAllRecords = async function (idapporig, idappdes
|
||||
|
||||
};
|
||||
|
||||
SettingsSchema.statics.findAllIdApp = function (idapp, serv) {
|
||||
SettingsSchema.statics.findAllIdApp = async function (idapp, serv, crypted = false) {
|
||||
const Settings = this;
|
||||
|
||||
let myfind = '';
|
||||
if (serv)
|
||||
myfind = { idapp, serv };
|
||||
else
|
||||
if (serv) {
|
||||
myfind = {idapp, serv };
|
||||
} else
|
||||
myfind = { idapp };
|
||||
|
||||
return Settings.find(myfind, (err, arrrec) => {
|
||||
// myfind = {...myfind, $or: [{ crypted: { $exists: false } }, { crypted: { $exists: true, $eq: crypted } }]};
|
||||
|
||||
const arrorig = await Settings.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
|
||||
let myarr = []
|
||||
|
||||
if (!crypted) {
|
||||
arrorig.forEach((rec) => {
|
||||
if (rec.crypted) {
|
||||
rec._doc.value_str = ''
|
||||
}
|
||||
myarr.push({...rec._doc});
|
||||
})
|
||||
} else {
|
||||
myarr = [...arrorig];
|
||||
}
|
||||
|
||||
return myarr;
|
||||
};
|
||||
|
||||
SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
|
||||
|
||||
Reference in New Issue
Block a user