// Contributors by alliance role api.get('/v1/alliance/:role', handler((req, res) => { const roles = getRoles(req.params.role); roles.push('everything'); return _(utils.loadFile(contributorsFile)) .filter(person => !_.isEmpty(_.intersection(roles, lca(person.role)))) .values(); }));
_this.requiresLogin(req, res, function() { if (_.intersection(req.user.roles, roles).length) { return next(); } else { return res.status(403).send({ message: 'User is not authorized' }); } });
const validatePlugins = function (pluginList) { return co(function* () { const existingPlugins = yield getAllPlugins(); const notExist = _.difference(pluginList, existingPlugins); if (notExist && notExist.length) { _.forEach(notExist, (x) => archLog.error(`arch plugin ${x} not found!`)); } return _.intersection(pluginList, existingPlugins); }); }
describe(`Query Collection Mock (${spec.name})`, () => { let availableContentTypes = _.intersection(spec.samples.petStore.consumes, spec.samples.petStore.produces); availableContentTypes.forEach((contentType) => { ["get", "head", "options"].forEach((method) => { describe(contentType, () => { describe(method.toUpperCase(), () => { testCases(spec, contentType, method); }); }); }); }); });
const paramsHasFields = (params, fields) => { return _.intersection(Object.keys(params || {}),fields).length > 0 }
M.findOne(Q).isactive().exec(function(err,Found){ if (err) return done(err); if (!Found || IsNew) Found = new M(Model); var Fields = _.intersection(_.keys(Model),CFG.EditFields); Fields.forEach(function(F){ Found[F] = Model[F]; }) Found.save(self.CodeUser,function(err){ if (err) return done(err); self.BaseModel = Found; return done(err); }) })
_loadAll(function(err,usersAll){ _loadGrps(self.CodeGrp,function(err,users1){ if (users1==null) users1 = usersAll; _loadRoles(self.CodeRole,function(err,users2){ if (users2==null) users2 = usersAll; return done(null,_.uniq(_.intersection(users1,users2))); }) }) })
router.put('/structure', HP.TaskAccess("IsRowTuner"), function(req,res,next){ var Context = req.body.Context, CodeUser = req.user.CodeUser, Row = mongoose.model("row"); var Rows = StructureHelper.ReparseRequest(req.body.Rows); StructureHelper.EnsureRootsExisits(_.keys(Rows),Context.CodeDoc,CodeUser,function(err){ if (err) return next(err); Helper.LoadRoots(Context.CodeDoc,function(err,CurrentRows){ if (err) return next(err); async.each(_.intersection(_.keys(CurrentRows),_.keys(Rows)),function(CodeRow,cb){ StructureHelper.UpdateRoot(CurrentRows[CodeRow],Rows[CodeRow],["NumRow","NameRow","CodeRowLink"],CodeUser,cb); },function(err){ if (err) return next(err); return res.json({}); }) }) }) })
/** * @param {} * @return {} * @api public */ var WordFormSimilarity = function (words1, words2) { var same_words = _.intersection(words1, words2) var result = 2 * same_words.length/(words1.length + words2.length) result = (isNaN(result)) ? 0 : result return result }
var _summ = function(Row){ var Summ = {Plus:[],Minus:[],Ignore:[]}; var Children = []; if (!_.isEmpty(Row.Sums)){ Children = _.filter(Rows,function(R){ return !_.isEmpty(_.intersection(R.Sums,Row.Sums)) && !R.IsSum; }) } else { Children = _.filter(Rows,{CodeParentRow:Row.CodeRow}); } Children.forEach(function(Child){ if (Child.NoSum) Summ.Ignore.push(Child.CodeRow); else if (Child.IsMinus) Summ.Minus.push(Child.CodeRow); else Summ.Plus.push(Child.CodeRow); }) return Summ; }
/** * Ensure the user can access the groups being updated to * @param {Object} currentUser the user who perform operation * @param {Object} data the challenge data to be updated * @param {String} challenge the original challenge data */ async function ensureAcessibilityToModifiedGroups (currentUser, data, challenge) { const needToCheckForGroupAccess = !currentUser ? true : !currentUser.isMachine && !helper.hasAdminRole(currentUser) if (!needToCheckForGroupAccess) { return } const userGroups = await helper.getUserGroups(currentUser.userId) const userGroupsIds = _.map(userGroups, group => group.id) const updatedGroups = _.difference(_.union(challenge.groups, data.groups), _.intersection(challenge.groups, data.groups)) const filtered = updatedGroups.filter(g => !userGroupsIds.includes(g)) if (filtered.length > 0) { throw new errors.ForbiddenError(`You don't have access to this group!`) } }
Objs.forEach(function(Obj2S){ var CodeKey = _.first(_.keys(Obj2S)); var Obj2W = _.first(_.values(Obj2S)); var Obj = {}; Obj[Cfg.Code] = CodeKey; for (var F in Obj2W){ Obj[F] = Obj2W[F].new; } var Fields2Save = _.intersection(_.keys(Obj),Cfg.EditFields); var O2Save = {}; Fields2Save.forEach(function(F){ if (Cfg.Booleans && Cfg.Booleans.indexOf(F)>=0) if (!Obj[F]) Obj[F] = 0; else Obj[F] = 1; if (Cfg.Numeric && Cfg.Numeric.indexOf(F)>=0) Obj[F] = parseInt(Obj[F]); O2Save[F] = Obj[F]; }) O2Save.tableName = Cfg.Table; O2Save.codeKey = Cfg.Code; Objects2Save.push(O2Save); })
_this.requireplyLogin(request, reply, function () { if (_.intersection(request.payload.user.roles, roles).length) { return reply.continue(); } else { return reply(Boom.forbidden('User is not authorized')); } });
// Contributors by alliance role api.get('/v1/alliance/:role', handler((req, res) => { const roles = getRoles(req.params.role); roles.push('everything'); return _(utils.loadFile(contributorsFile)) .filter(person => !_.isEmpty(_.intersection(roles, lca(person.role)))) .values(); }));
router.put('/structure', HP.TaskAccess("IsRowTuner"), function(req,res,next){ var Context = req.body.Context, CodeUser = req.user.CodeUser, Row = mongoose.model("row"); var Rows = StructureHelper.ReparseRequest(req.body.Rows); StructureHelper.EnsureRootsExisits(_.keys(Rows),Context.CodeDoc,CodeUser,function(err){ if (err) return next(err); Helper.LoadRoots(Context.CodeDoc,function(err,CurrentRows){ if (err) return next(err); async.each(_.intersection(_.keys(CurrentRows),_.keys(Rows)),function(CodeRow,cb){ StructureHelper.UpdateRoot(CurrentRows[CodeRow],Rows[CodeRow],["NumRow","NameRow","CodeRowLink"],CodeUser,cb); },function(err){ if (err) return next(err); return res.json({}); }) }) }) })