Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/access-strategy-types/or.js
Show All 14 Lines | const or = { | ||||
getRestrictingQuery: async function(context, params) { | getRestrictingQuery: async function(context, params) { | ||||
const access_strategies = parse_params(app, params); | const access_strategies = parse_params(app, params); | ||||
const queries = await Promise.map(access_strategies, strategy => | const queries = await Promise.map(access_strategies, strategy => | ||||
strategy.getRestrictingQuery(context) | strategy.getRestrictingQuery(context) | ||||
); | ); | ||||
if (queries.some(query => query instanceof Query.AllowAll)) { | if (queries.some(query => query instanceof Query.AllowAll)) { | ||||
return new Query.AllowAll(); | return new Query.AllowAll(); | ||||
} | } | ||||
return Promise.reduce( | return new Query.Or(...queries); | ||||
queries, | |||||
async (aggregated, query) => { | |||||
aggregated.addQuery(query); | |||||
return aggregated; | |||||
}, | |||||
new Query.Or() | |||||
); | |||||
}, | }, | ||||
item_sensitive: function(params) { | item_sensitive: function(params) { | ||||
const access_strategies = parse_params(app, params); | const access_strategies = parse_params(app, params); | ||||
return Promise.map(access_strategies, function(access_strategy) { | return Promise.map(access_strategies, function(access_strategy) { | ||||
return access_strategy.is_item_sensitive(); | return access_strategy.is_item_sensitive(); | ||||
}).reduce((a, b) => a || b); | }).reduce((a, b) => a || b); | ||||
}, | }, | ||||
checker_function: function(context, params, item) { | checker_function: function(context, params, item) { | ||||
Show All 32 Lines |