How to use the @casl/ability/extra.permittedFieldsOf function in @casl/ability

To help you get started, we’ve selected a few @casl/ability examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stalniy / casl / packages / casl-mongoose / src / accessible_fields.js View on Github external
function accessibleFieldsBy(ability, action = 'read') {
    if (!fieldsFrom) {
      const ALL_FIELDS = options.only ? wrapArray(options.only) : fieldsOf(schema, options);
      fieldsFrom = rule => rule.fields || ALL_FIELDS;
    }

    const subject = typeof this === 'function' ? this.modelName : this;

    return permittedFieldsOf(ability, action, subject, { fieldsFrom });
  }
  const permittedFieldsBy = deprecate('permittedFieldsBy', {

@casl/ability

CASL is an isomorphic authorization JavaScript library which restricts what resources a given user is allowed to access

MIT
Latest version published 24 days ago

Package Health Score

88 / 100
Full package analysis