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';
|
||||
|
||||
const constants = require('../libs/constants');
|
||||
|
||||
module.exports = {
|
||||
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){
|
||||
for(var i=0; i<keys.length; i++){
|
||||
var curr_key = keys[i];
|
||||
|
@ -20,22 +15,22 @@ module.exports = {
|
|||
|
||||
switch(type){
|
||||
case 'private_form':
|
||||
removeKeysFromDict(object, privateFields[type]);
|
||||
removeKeysFromDict(object, constants.privateFields[type]);
|
||||
if(object.admin){
|
||||
removeKeysFromDict(object.admin, privateFields.private_user);
|
||||
removeKeysFromDict(object.admin, constants.privateFields.private_user);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'public_form':
|
||||
removeKeysFromDict(object, privateFields[type]);
|
||||
removeKeysFromDict(object, constants.privateFields[type]);
|
||||
if(object.admin){
|
||||
removeKeysFromDict(object.admin, privateFields.public_user);
|
||||
removeKeysFromDict(object.admin, constants.privateFields.public_user);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if(privateFields.hasOwnProperty(type)){
|
||||
removeKeysFromDict(object, privateFields[type]);
|
||||
if(constants.privateFields.hasOwnProperty(type)){
|
||||
removeKeysFromDict(object, constants.privateFields[type]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,13 @@ module.exports = {
|
|||
'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',
|
||||
'field != static',
|
||||
'field > static',
|
||||
|
|
Loading…
Reference in a new issue