Return if a user can perform an action on a certain resource

@param  {Object}   options { resource, action, userId,  }
@param  {Function} cb
505298
function batchAuthorization ({ resourceBatch, userId, organizationId, sourceIpAddress, sourcePort }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      async.waterfall([
        function validate (next) {
          Joi.validate({ resourceBatch, userId, organizationId }, validationRules.batchAuthorization, badRequestWrap(next))
        },
        function listPolicies (result, next) {
          policyOps.listAllUserPolicies({ userId, organizationId }, badImplementationWrap(next))
        },
        function check (policies, next) {
          let context = buildContext({userId, organizationId, sourceIpAddress, sourcePort})

          resourceBatch.forEach((rb) => {
            rb.access = iam(policies).isAuthorized({resource: rb.resource, action: rb.action, context})
          })
          next(null, resourceBatch)
        }
      ], function (err, access) {
        cb(err, resourceBatch)
      })

      return promise
    }
1190530
function func2(data, cb, resource) {
  let error
  log.debug('Calling func2', data)
  cb(error)
  return false
}
336335
function (list, cb) {
            can.each(list, function (item, i) {
                cb(item, i, list)
            })
        }
916722
function (db, options, cb) {
	this.db = db;
	this.cb = cb;
	this.updateQueryMaker = options.update;
	this.insertQueryMaker = options.insert;
	this.maxUpdateAttemptsCount = options.maxUpdateAttemptsCount || 2;
	this.transform = options.transform;
	this.insertFirst = !!options.insertFirst;
	this.nonQuery = !!options.nonQuery;

	var self = this;
	this.updateAttemptsCount = 0;
	this.updateOrInsertBound = function () {
		self.updateOrInsert();
	};
}
415757
function(options) {

    var self = this;

    console.log('options are', options);

    this.connected = false;

    this.config = this.getConfig(options);

    this.cbSocketWrapper = new CBSocketWrapper(this.config);

    this.cbSocketWrapper.on('connect', function(message) {
        self.connected = true;
        self.emit('connect');
        logger.log('debug', 'Client connect');
    });

    this.cbSocketWrapper.on('disconnect', function(message) {
        self.connected = false;
        self.emit('disconnect');
    });

    this.cbSocketWrapper.on('message', function(message) {

        self.emit('message', message);

        var source = message.get('source');
        self.emit(source, message);
        //logger.info('CB => Client: ', message)
    });

    // Restart connection process on 'giveUp'
    this.cbSocketWrapper.on('fail', function() {
        self.cbSocketWrapper.giveUp();
        self.connect();
    });

    this.faultTolerantAuth = retry.operation()

    this.connect();
}
1006578
function(model, id, settings, options, cb) {
      var defaultSelect, query;
      if (settings == null) {
        settings = {};
      }
      if (options == null) {
        options = {};
      }
      if (cb == null) {
        cb = function() {};
      }
      Hoek.assert(model, i18n.assertModuleRequired);
      Hoek.assert(id, i18n.assertIdRequired);
      defaultSelect = settings.defaultSelect || null;
      if (_.isFunction(options)) {
        cb = options;
        options = {};
      }
      options.select || (options.select = defaultSelect);
      query = model.findOne({
        _id: asObjectId(id)
      });
      if (options.select && options.select.length > 0) {
        query = query.select(options.select);
      }
      return query.exec(cb);
    }
1278999
function hasRole(rbac, role, cb) {
  if (!this.role) {
    cb(null, false);
    return this;
  }

  // check existance of permission
  rbac.hasRole(this.role, role, cb);
  return this;
}
1007335
def ndr_can?(action, subject, *extra_args)
      return true unless respond_to?(:can?)

      unless subject.is_a?(ActiveRecord::Base)
        ActiveSupport::Deprecation.warn(<<~MSG)
          Attempting to authorise a non-resource object causes authorisation to be skipped.
          In future, this behaviour may change; please use a resource where possible.
        MSG

        return true
      end

      can?(action, subject, *extra_args)
    end
1291016
function (pageRequest, cb) {
            var pageId = pageRequest.pageId;
            var forceReload = pageRequest.forceReload;
            if (!forceReload && pageId && pageId == this.currentPageId) {
                this.$callback(cb);
                if (this._navigationManager) {
                    this._navigationManager.update(pageRequest);
                    ariaUtilsJson.setValue(this._data, "pageInfo", pageRequest);
                }
            } else {
                this._previousPageCSS = this._currentPageCSS;
                this._currentPageCSS = [];
                this._pageProvider.loadPageDefinition(pageRequest, {
                    onsuccess : {
                        fn : this._getPageDependencies,
                        scope : this,
                        args : {
                            pageRequest : pageRequest,
                            cb : cb
                        }
                    },
                    onfailure : this._getErrorCallbackConfig([this.PAGE_NOT_AVAILABLE, pageId])
                });
            }
        }
293900
function setPossibleStates(id, objarr, options, cb) {
    if (!adapter) return cb && cb('adapter not set');
	if (options === undefined) options = {};
    if (typeof options === 'function') {
        cb = options;
        options = {};
    }
    adapter.getObject(id, function(err, obj) {
        if (err || !obj) return;
        if (objarr.remove || options.remove) {
            if (obj.common.states === undefined) return cb && cb('does not exist');
            delete obj.common.states;
        } else {
            if (!options.force && obj.common.states) return cb && cb('already set');
            obj.common.states = {};
            if (Array.isArray(objarr)) {
                objarr.forEach(function (v) {
                    obj.common.states[v] = v;
                });
            } else {
                obj.common.states = objarr;
            }
        }
        if (options.removeNativeValues && obj.native) delete obj.native.values;
        adapter.setObject(id, obj, function(err, _obj) {
            cb && cb(err, obj);
        });
    })
}
1187022
function addPermission(rbac, action, resource, cb) {
  rbac.getPermission(action, resource, (err, permission) => {
    if (err) {
      return cb(err);
    }

    if (!permission) {
      return cb(new Error('Permission not exists'));
    }

    if (indexOf(this.permissions, permission.name) !== -1) {
      return cb(new Error('Permission is already assigned'));
    }

    this.permissions.push(permission.name);
    return this.save((err2, user) => {
      if (err2) {
        return cb(err2);
      }

      if (!user) {
        return cb(new Error('User is undefined'));
      }

      return cb(null, true);
    });
  });

  return this;
}
1286396
function enable(options, cb) {
  options = options || {};
  var travis = new Travis({
    version: '2.0.0',
    // user-agent needs to start with "Travis"
    // https://github.com/travis-ci/travis-ci/issues/5649
    headers: {'user-agent': 'Travis: jonschlinkert/enable-travis'}
  });

  travis.auth.github.post({
    github_token: options.GITHUB_OAUTH_TOKEN
  }, function(err, res) {
    if (err) return cb(err);

    travis.authenticate({
      access_token: res.access_token
    }, function(err) {

      if (err) return cb(err);
      var segs = options.repo.split('/');

      travis.repos(segs[0], segs[1]).get(function(err, res) {
        if (err) return cb(err);

        travis.hooks(res.repo && res.repo.id).put({
          hook: {active: true}

        }, function(err, content) {
          if (err) return cb(err);
          cb(null, content);
        });
      });
    });
  });
}
201266
function all(options, cb) {
  var q
    , page = Number(options.page) || 1
    , limit = Number(options.limit) || conf.objects_by_page
    , offset = (page - 1) * limit;

  count(function(err, count) {
    if(err) { return cb(err); }

    q = select('LEFT JOIN');
    q += ' LIMIT ' + limit + ' OFFSET ' + offset;

    db.getClient(function(err, client, done) {
      client.query(q, function(err, r) {
        if(err) {
          cb(err);
          done(err);
        } else {
          cb(null, {
            rows: r.rows,
            count: count,
            limit: limit,
            offset: offset,
            page: page
          });
          done();
        }
      });
    });
  });
}
787077
public boolean canLockBecauseOfInactivity(CmsObject cms, CmsUser user) {

        return !user.isManaged()
            && !user.isWebuser()
            && !OpenCms.getDefaultUsers().isDefaultUser(user.getName())
            && !OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ROOT_ADMIN);
    }
871428
function (url, cb) {

            var request = new XMLHttpRequest();

            request.onload = function () {
                if (this.status >= 200 && this.status < 400) {
                    cb(this.response);
                }
                else {
                    Logger.log(Logger.LEVEL_SEVERE, "sever error: " + this.status);
                    cb(null);
                }
            };

            request.onerror = function (e) {
                Logger.log(Logger.LEVEL_SEVERE, "connection error: " + e);
                cb(null);
            };

            request.open("get", url, true);

            request.send();
        }
1031732
def arecord_user_action_on_item(action, uid, iid, optional = {})
      optional['targetEntityType'] = 'item'
      optional['targetEntityId'] = iid
      acreate_event(action, 'user', uid, optional)
    end
800216
function(cb) {
          var opts = {
            url: uri + 'user/stream',
            method: 'GET',
            qs: qs,
            json: true
          };
          request(opts,function(e,r,b) {
            if (e) cb(e)
            else {
              if (r.statusCode==200) cb(null, b)
              else {
                cb({statusCode:r.statusCode,error:b.error})
              }
            }
          });
        }