lib/secureAccessMethods.js
function readAllSecure(user, options) {
    // jscs:disable
    // jshint -W040
    const self = this;
    // jshint +W040
    // jscs:enable
    const shield = self.constructor.shield;
    const action = 'read';
    const rules = shield.getApplicableRules(action);
    return shield._fetchAll.call(self, options)
        .then(function runShieldRules(collection) {
            // TODO: investigate what happens if fetch returns nothing (err?)
            return collection.mapThen((mdl) => applyRules(rules, mdl, user))
                .then(function resolveResult() {
                    return collection;
                });
        });
}
function readAllSecure(user, options) {
    // jscs:disable
    // jshint -W040
    const self = this;
    // jshint +W040
    // jscs:enable
    const shield = self.constructor.shield;
    const action = 'read';
    const rules = shield.getApplicableRules(action);
    return shield._fetchAll.call(self, options)
        .then(function runShieldRules(collection) {
            // TODO: investigate what happens if fetch returns nothing (err?)
            return collection.mapThen((mdl) => applyRules(rules, mdl, user))
                .then(function resolveResult() {
                    return collection;
                });
        });
}
function readAllSecure ( user , options ) { // jscs:disable // jshint -W040 const self = this ; // jshint +W040 // jscs:enable const shield = self . constructor . shield ; const action = 'read' ; const rules = shield . getApplicableRules ( action ) ; return shield . _fetchAll . call ( self , options ) . then ( function runShieldRules ( collection ) { // TODO: investigate what happens if fetch returns nothing (err?) return collection . mapThen ( ( mdl ) => applyRules ( rules , mdl , user ) ) . then ( function resolveResult ( ) { return collection ; } ) ; } ) ; }
Fetch All records from DB, then verify permissions
@param {object} user is the user credentials
@param {object} options are options to be passed to destroy call
@return {Promise} resolves to fetchAll result or rejects with auth error
Fetch All records from DB then verify permissions