@budibase/backend-core 2.33.11 → 2.33.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -69702,7 +69702,7 @@ function getBuiltinRole(roleId) {
69702
69702
  function builtinRoleToNumber(id) {
69703
69703
  const builtins = getBuiltinRoles();
69704
69704
  const MAX = Object.values(builtins).length + 1;
69705
- if (id === BUILTIN_IDS.ADMIN || id === BUILTIN_IDS.BUILDER) {
69705
+ if (compareRoleIds(id, BUILTIN_IDS.ADMIN) || compareRoleIds(id, BUILTIN_IDS.BUILDER)) {
69706
69706
  return MAX;
69707
69707
  }
69708
69708
  let role = builtins[id], count = 0;
@@ -69732,7 +69732,9 @@ async function roleToNumber(id) {
69732
69732
  }
69733
69733
  if (Array.isArray(role.inherits)) {
69734
69734
  const highestBuiltin = role.inherits.map((roleId) => {
69735
- const foundRole = hierarchy.find((role2) => role2._id === roleId);
69735
+ const foundRole = hierarchy.find(
69736
+ (role2) => compareRoleIds(role2._id, roleId)
69737
+ );
69736
69738
  if (foundRole) {
69737
69739
  return findNumber(foundRole) + 1;
69738
69740
  }
@@ -69809,7 +69811,7 @@ async function saveRoles(roles) {
69809
69811
  }
69810
69812
  async function getAllUserRoles(userRoleId, opts) {
69811
69813
  const allRoles = await getAllRoles();
69812
- if (userRoleId === BUILTIN_IDS.ADMIN) {
69814
+ if (compareRoleIds(userRoleId, BUILTIN_IDS.ADMIN)) {
69813
69815
  return allRoles;
69814
69816
  }
69815
69817
  const foundRole = findRole(userRoleId, allRoles, opts);
@@ -69884,14 +69886,19 @@ async function getAllRoles(appId) {
69884
69886
  for (let builtinRoleId of externalBuiltinRoles) {
69885
69887
  const builtinRole = builtinRoles[builtinRoleId];
69886
69888
  const dbBuiltin = roles.filter(
69887
- (dbRole) => getExternalRoleID(dbRole._id, dbRole.version) === builtinRoleId
69889
+ (dbRole) => compareRoleIds(dbRole._id, builtinRoleId)
69888
69890
  )[0];
69889
69891
  if (dbBuiltin == null) {
69890
69892
  roles.push(builtinRole || builtinRoles.BASIC);
69891
69893
  } else {
69892
69894
  roles = roles.filter((role) => role._id !== dbBuiltin._id);
69893
- dbBuiltin._id = getExternalRoleID(dbBuiltin._id, dbBuiltin.version);
69894
- roles.push(Object.assign(builtinRole, dbBuiltin));
69895
+ dbBuiltin._id = getExternalRoleID(builtinRole._id, dbBuiltin.version);
69896
+ roles.push({
69897
+ ...builtinRole,
69898
+ ...dbBuiltin,
69899
+ name: builtinRole.name,
69900
+ _id: getExternalRoleID(builtinRole._id, builtinRole.version)
69901
+ });
69895
69902
  }
69896
69903
  }
69897
69904
  for (let role of roles) {
@@ -69922,7 +69929,7 @@ var AccessController = class {
69922
69929
  this.userHierarchies = {};
69923
69930
  }
69924
69931
  async hasAccess(tryingRoleId, userRoleId) {
69925
- if (tryingRoleId == null || tryingRoleId === "" || tryingRoleId === userRoleId || tryingRoleId === BUILTIN_IDS.BUILDER || userRoleId === BUILTIN_IDS.BUILDER) {
69932
+ if (tryingRoleId == null || tryingRoleId === "" || compareRoleIds(tryingRoleId, BUILTIN_IDS.BUILDER) || compareRoleIds(userRoleId, tryingRoleId) || compareRoleIds(userRoleId, BUILTIN_IDS.BUILDER)) {
69926
69933
  return true;
69927
69934
  }
69928
69935
  let roleIds = userRoleId ? this.userHierarchies[userRoleId] : null;