Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should have one or more of each section', function() {
var newObj = _.pick( _sheet, opts.sections );
expect( Object.keys(newObj).length ).to.equal( opts.sections.length );
});
router.post('/', (req,res) => {
let validAttributes = _.pick(req.body, 'username', 'email', 'password');
let newUser = new User (validAttributes);
newUser.save((err,user) => {
if(err){
if(err.code === 11000) {
if(/username/.test(err.message) || /lowercase_name/.test(err.message)) {
return res.status(500).json({
success: false,
message: 'Name is taken :('});
} else {
return res.status(500).json({
success: false,
message: 'Mail is taken :(',
error: err.message
});
}
} else {
_.each(attributes, function(attributeValue, attributeKey) {
var mergeProps = {};
if (_.keys(attributeValue).length) {
var specialProps = _.pick(attributeValue, specialPropNamesKeys);
_.each(specialProps, function(specialProp, specialPropName) {
var localMergeProp = {};
var protoName = specialPropNames[specialPropName];
protoProps[protoName] = protoProps[protoName] || {};
localMergeProp[attributeKey] = specialProp;
protoProps[protoName] = _.defaults(protoProps[protoName], localMergeProp);
});
var filteredProps = _.omit(attributeValue, specialPropNamesKeys);
if (!_.isEmpty(filteredProps)) {
mergeProps[attributeKey] = filteredProps;
_.defaults(protoProps, mergeProps);
}
} else {
mergeProps[attributeKey] = attributeValue;
const result = await ctx.service.auth.user.edit(query.id);
if (!result) {
this.failure({
data: {
id: query.id,
},
state: 404,
});
return false;
}
this.success(_.pick(result, ...[ 'id', 'account', 'name', 'sex', 'mobile', 'email', 'remark' ]));
}
initialize: function(options) {
_.extend(this, _.pick(options, 'auditFilterType'));
AuditFilter.__super__.initialize.call(this, options);
},
get() {
if (!hasPermission(this.userId, 'view-privileged-setting')) {
return API.v1.unauthorized();
}
return API.v1.success(_.pick(Settings.findOneNotHiddenById(this.urlParams._id), '_id', 'value'));
},
post() {
_pickAttrs: function (legendDefinitionModel) {
var attrs = _.pick(legendDefinitionModel.attributes, 'title', 'prefix', 'suffix', 'leftLabel', 'rightLabel', 'topLabel', 'bottomLabel', 'items');
return attrs;
},
RestberryObj.prototype._save = function(next) {
var _lockedFields = this._lockedFields;
var obj = _.pick(this, function(val, key) {
return !_.contains(_lockedFields, key);
});
for (var key in obj) {
this._obj[key] = obj[key];
}
this.restberry.odm.save(this._obj, next);
};
const campaignId = campaign.campaignId
if (campaigns[campaignId]) return oops('duplicated campaignId: ' + campaignId)
const startTimestamp = new Date(campaign.startAt).getTime()
if (isNaN(startTimestamp)) return oops('invalid startAt for campaignId: ' + campaignId)
const stopTimestamp = new Date(campaign.endAt).getTime()
if (isNaN(stopTimestamp)) return oops('invalid endAt for campaignId: ' + campaignId)
if (stopTimestamp <= now) return
const regions = []
if (campaign.geoTargets) {
campaign.geoTargets.forEach((region) => { regions.push(region.code) })
}
campaigns[campaignId] = underscore.extend({ startTimestamp, stopTimestamp, creativeSets: 0, regions: regions },
underscore.pick(campaign, [ 'name', 'dailyCap', 'budget' ]))
campaign.creativeSets.forEach((creativeSet) => {
if (failP) return
if (creativeSet.execution !== 'per_click') return oops('creativeSet with unknown execution: ' + creativeSet.execution)
const creativeSetId = creativeSet.creativeSetId
if (creativeSets[creativeSetId]) return oops('duplicated creativeSetId: ' + creativeSetId)
let hierarchy = []
creativeSet.segments.forEach((segment) => {
const name = segment.name.toLowerCase()
if (hierarchy.indexOf(name) === -1) hierarchy.push(name)
})
if (hierarchy.length === 0) return oops('creativeSet with no segments: ' + creativeSetId)