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 commit is contained in:
parent
ad46ff6f8c
commit
0cd05a4adf
|
@ -208,6 +208,11 @@ export function getAutomationId(): string | undefined {
|
||||||
return context?.automationId
|
return context?.automationId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hasAppId(): boolean {
|
||||||
|
const appId = getAppId()
|
||||||
|
return !!appId
|
||||||
|
}
|
||||||
|
|
||||||
export function getAppId(): string | undefined {
|
export function getAppId(): string | undefined {
|
||||||
const context = Context.get()
|
const context = Context.get()
|
||||||
const foundId = context?.appId
|
const foundId = context?.appId
|
||||||
|
|
|
@ -84,13 +84,16 @@ export async function allowsExplicitPermissions(resourceId: string) {
|
||||||
export async function getResourcePerms(
|
export async function getResourcePerms(
|
||||||
resourceId: string
|
resourceId: string
|
||||||
): Promise<ResourcePermissions> {
|
): Promise<ResourcePermissions> {
|
||||||
const db = context.getAppDB()
|
let rolesList: Role[] = []
|
||||||
const body = await db.allDocs(
|
if (context.hasAppId()) {
|
||||||
getRoleParams(null, {
|
const db = context.getAppDB()
|
||||||
include_docs: true,
|
const body = await db.allDocs(
|
||||||
})
|
getRoleParams(null, {
|
||||||
)
|
include_docs: true,
|
||||||
const rolesList = body.rows.map<Role>(row => row.doc)
|
})
|
||||||
|
)
|
||||||
|
rolesList = body.rows.map<Role>(row => row.doc)
|
||||||
|
}
|
||||||
let permissions: ResourcePermissions = {}
|
let permissions: ResourcePermissions = {}
|
||||||
|
|
||||||
const permsToInherit = await getInheritablePermissions(resourceId)
|
const permsToInherit = await getInheritablePermissions(resourceId)
|
||||||
|
@ -128,8 +131,7 @@ export async function getResourcePerms(
|
||||||
p[level] = { role, type: PermissionSource.BASE }
|
p[level] = { role, type: PermissionSource.BASE }
|
||||||
return p
|
return p
|
||||||
}, {})
|
}, {})
|
||||||
const result = Object.assign(basePermissions, permissions)
|
return Object.assign(basePermissions, permissions)
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDependantResources(
|
export async function getDependantResources(
|
||||||
|
|
Loading…
Reference in New Issue