moved privateFields dict to constants.js
This commit is contained in:
parent
75d06037a3
commit
a165cdc242
2 changed files with 15 additions and 13 deletions
|
@ -1,14 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const constants = require('../libs/constants');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
removeSensitiveModelData: function(type, object){
|
removeSensitiveModelData: function(type, object){
|
||||||
var privateFields = {
|
|
||||||
'public_form': ['__v', 'analytics.visitors', 'analytics.views', 'analytics.conversionRate', 'analytics.fields', 'lastModified', 'created'],
|
|
||||||
'private_form': ['__v'],
|
|
||||||
'public_user': ['passwordHash', 'password', 'provider', 'salt', 'lastModified', 'created', 'resetPasswordToken', 'resetPasswordExpires', 'token', 'apiKey', '__v'],
|
|
||||||
'private_user': ['passwordHash', 'password', 'provider', 'salt', 'resetPasswordToken', 'resetPasswordExpires', 'token', '__v']
|
|
||||||
};
|
|
||||||
|
|
||||||
function removeKeysFromDict(dict, keys){
|
function removeKeysFromDict(dict, keys){
|
||||||
for(var i=0; i<keys.length; i++){
|
for(var i=0; i<keys.length; i++){
|
||||||
var curr_key = keys[i];
|
var curr_key = keys[i];
|
||||||
|
@ -20,22 +15,22 @@ module.exports = {
|
||||||
|
|
||||||
switch(type){
|
switch(type){
|
||||||
case 'private_form':
|
case 'private_form':
|
||||||
removeKeysFromDict(object, privateFields[type]);
|
removeKeysFromDict(object, constants.privateFields[type]);
|
||||||
if(object.admin){
|
if(object.admin){
|
||||||
removeKeysFromDict(object.admin, privateFields.private_user);
|
removeKeysFromDict(object.admin, constants.privateFields.private_user);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'public_form':
|
case 'public_form':
|
||||||
removeKeysFromDict(object, privateFields[type]);
|
removeKeysFromDict(object, constants.privateFields[type]);
|
||||||
if(object.admin){
|
if(object.admin){
|
||||||
removeKeysFromDict(object.admin, privateFields.public_user);
|
removeKeysFromDict(object.admin, constants.privateFields.public_user);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(privateFields.hasOwnProperty(type)){
|
if(constants.privateFields.hasOwnProperty(type)){
|
||||||
removeKeysFromDict(object, privateFields[type]);
|
removeKeysFromDict(object, constants.privateFields[type]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,13 @@ module.exports = {
|
||||||
'Deutsch': 'de'
|
'Deutsch': 'de'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
privateFields: {
|
||||||
|
'public_form': ['__v', 'analytics.visitors', 'analytics.views', 'analytics.conversionRate', 'analytics.fields', 'lastModified', 'created'],
|
||||||
|
'private_form': ['__v'],
|
||||||
|
'public_user': ['passwordHash', 'password', 'provider', 'salt', 'lastModified', 'created', 'resetPasswordToken', 'resetPasswordExpires', 'token', 'apiKey', '__v'],
|
||||||
|
'private_user': ['passwordHash', 'password', 'provider', 'salt', 'resetPasswordToken', 'resetPasswordExpires', 'token', '__v']
|
||||||
|
},
|
||||||
|
|
||||||
expressionStringTypes: ['field == static',
|
expressionStringTypes: ['field == static',
|
||||||
'field != static',
|
'field != static',
|
||||||
'field > static',
|
'field > static',
|
||||||
|
|
Loading…
Reference in a new issue