From 9c32f278b7671cdaba51bc1e52f293d7d2829235 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 6 Sep 2023 10:09:45 +0100 Subject: [PATCH] Revert "Quick fix issue integration tests have displayed, retrieving users through the public API was broken due to a lack of app ID in context." This reverts commit 0cd05a4adf1bcf1e44afd8393c32e67a3cad28e8. --- .../backend-core/src/context/mainContext.ts | 5 ----- .../server/src/sdk/app/permissions/index.ts | 20 +++++++++---------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/backend-core/src/context/mainContext.ts b/packages/backend-core/src/context/mainContext.ts index f85b757e83..61d96bb4b0 100644 --- a/packages/backend-core/src/context/mainContext.ts +++ b/packages/backend-core/src/context/mainContext.ts @@ -208,11 +208,6 @@ export function getAutomationId(): string | undefined { return context?.automationId } -export function hasAppId(): boolean { - const appId = getAppId() - return !!appId -} - export function getAppId(): string | undefined { const context = Context.get() const foundId = context?.appId diff --git a/packages/server/src/sdk/app/permissions/index.ts b/packages/server/src/sdk/app/permissions/index.ts index 1c3f4f0fbd..53f6756ae1 100644 --- a/packages/server/src/sdk/app/permissions/index.ts +++ b/packages/server/src/sdk/app/permissions/index.ts @@ -84,16 +84,13 @@ export async function allowsExplicitPermissions(resourceId: string) { export async function getResourcePerms( resourceId: string ): Promise { - let rolesList: Role[] = [] - if (context.hasAppId()) { - const db = context.getAppDB() - const body = await db.allDocs( - getRoleParams(null, { - include_docs: true, - }) - ) - rolesList = body.rows.map(row => row.doc) - } + const db = context.getAppDB() + const body = await db.allDocs( + getRoleParams(null, { + include_docs: true, + }) + ) + const rolesList = body.rows.map(row => row.doc) let permissions: ResourcePermissions = {} const permsToInherit = await getInheritablePermissions(resourceId) @@ -131,7 +128,8 @@ export async function getResourcePerms( p[level] = { role, type: PermissionSource.BASE } return p }, {}) - return Object.assign(basePermissions, permissions) + const result = Object.assign(basePermissions, permissions) + return result } export async function getDependantResources(