'use strict';

module.exports = {
  getAuthorizedAclMethods,
};

function getAuthorizedAclMethods(Model) {
  let authorizedMethods = [];
  let acls = Model.definition.settings.acls || [];

  acls.forEach((acl) => {
    if (acl.permission === 'ALLOW' && acl.property) {
      if (!Array.isArray(acl.property)) {
        acl.property = [acl.property];
      }
      authorizedMethods = authorizedMethods.concat(acl.property);
    }
  });

  return authorizedMethods;
}

'use strict';

module.exports = {
  getAuthorizedAclMethods,
};

function getAuthorizedAclMethods(Model) {
  let authorizedMethods = [];
  let acls = Model.settings.acls || [];

  acls.forEach((acl) => {
    if (acl.permission === 'ALLOW' && acl.property) {
      if (!Array.isArray(acl.property)) {
        acl.property = [acl.property];
      }
      authorizedMethods = authorizedMethods.concat(acl.property);
    }
  });

  return authorizedMethods;
}

Use Model.settings.acls to get the acls
Use Model.settings.acls to get the acls

Use `Model.settings.acls` to get the acls instead of `Model.definition.settings.acl`. `Model.definition` is an artifact created by datasource-juggler, but it wouldn't exists if you just use `loopback.createModel()`.