diff --git a/packages/backend-core/src/environment.ts b/packages/backend-core/src/environment.ts index 7d3a9f18f5..4cb0a9c731 100644 --- a/packages/backend-core/src/environment.ts +++ b/packages/backend-core/src/environment.ts @@ -223,6 +223,8 @@ const environment = { BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL, BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD, OPENAI_API_KEY: process.env.OPENAI_API_KEY, + MIN_VERSION_WITHOUT_POWER_ROLE: + process.env.MIN_VERSION_WITHOUT_POWER_ROLE || "3.0.0", } export function setEnv(newEnvVars: Partial): () => void { diff --git a/packages/backend-core/src/security/roles.ts b/packages/backend-core/src/security/roles.ts index df7f41e6ce..76c4f08fbe 100644 --- a/packages/backend-core/src/security/roles.ts +++ b/packages/backend-core/src/security/roles.ts @@ -19,6 +19,7 @@ import { import cloneDeep from "lodash/fp/cloneDeep" import { RoleColor, helpers } from "@budibase/shared-core" import { uniqBy } from "lodash" +import { default as env } from "../environment" export const BUILTIN_ROLE_IDS = { ADMIN: "ADMIN", @@ -545,7 +546,10 @@ async function shouldIncludePowerRole(db: Database) { return true } - const isGreaterThan3x = semver.gte(creationVersion, "3.0.0") + const isGreaterThan3x = semver.gte( + creationVersion, + env.MIN_VERSION_WITHOUT_POWER_ROLE + ) return !isGreaterThan3x } diff --git a/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte index 2826d8d986..17c26847b3 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/ManageAccessButton.svelte @@ -34,7 +34,9 @@ $: buttonLabel = readableRole ? `Access: ${readableRole}` : "Access" $: highlight = roleMismatch || selectedRole === Roles.PUBLIC - $: builtInRoles = builtins.map(roleId => $roles.find(x => x._id === roleId)) + $: builtInRoles = builtins + .map(roleId => $roles.find(x => x._id === roleId)) + .filter(r => !!r) $: customRoles = $roles .filter(x => !builtins.includes(x._id)) .slice()