lib/secureAccessMethods.js
function applyRules(rules, model, user) {
    const rulePromises = _.map(rules, (rule) => rule.applyTo(model, user));
    return Promise.all(rulePromises)

        //TODO validate rule results to handle optional vs. required auth...
        .catch(function catchAuthError(error) {
            return Promise.reject(error);
        });
}
function applyRules(rules, model, user) {
    const rulePromises = _.map(rules, (rule) => rule.applyTo(model, user));
    return Promise.all(rulePromises)

        //TODO validate rule results to handle optional vs. required auth...
        .catch(function catchAuthError(error) {
            return Promise.reject(error);
        });
}
function applyRules ( rules , model , user ) { const rulePromises = _ . map ( rules , ( rule ) => rule . applyTo ( model , user ) ) ; return Promise . all ( rulePromises ) //TODO validate rule results to handle optional vs. required auth... . catch ( function catchAuthError ( error ) { return Promise . reject ( error ) ; } ) ; }
Iterate through rules and apply each one on the model and user
@param {array} rules is an array of Rule objects
@param {object} models is a bookshelf model instance
@param {object} user is the user credentials
@return {Promise} resolves to array of rule results,
or rejects with AuthorizationError.
Iterate through rules and apply each one on the model and user