Some type updates and fixes for test case.
This commit is contained in:
parent
bedc8e5cce
commit
1bdf55e966
|
@ -165,7 +165,7 @@ export async function getRole(
|
||||||
// finalise the ID
|
// finalise the ID
|
||||||
role._id = getExternalRoleID(role._id)
|
role._id = getExternalRoleID(role._id)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (opts?.defaultPublic) {
|
if (!isBuiltin(roleId) && opts?.defaultPublic) {
|
||||||
return cloneDeep(BUILTIN_ROLES.PUBLIC)
|
return cloneDeep(BUILTIN_ROLES.PUBLIC)
|
||||||
}
|
}
|
||||||
// only throw an error if there is no role at all
|
// only throw an error if there is no role at all
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getRoutingInfo } from "../../utilities/routing"
|
import { getRoutingInfo } from "../../utilities/routing"
|
||||||
import { roles } from "@budibase/backend-core"
|
import { roles } from "@budibase/backend-core"
|
||||||
import { BBContext } from "@budibase/types"
|
import { UserCtx } from "@budibase/types"
|
||||||
|
|
||||||
const URL_SEPARATOR = "/"
|
const URL_SEPARATOR = "/"
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ async function getRoutingStructure() {
|
||||||
return { routes: routing.json }
|
return { routes: routing.json }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetch(ctx: BBContext) {
|
export async function fetch(ctx: UserCtx) {
|
||||||
ctx.body = await getRoutingStructure()
|
ctx.body = await getRoutingStructure()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function clientFetch(ctx: BBContext) {
|
export async function clientFetch(ctx: UserCtx) {
|
||||||
const routing = await getRoutingStructure()
|
const routing = await getRoutingStructure()
|
||||||
let roleId = ctx.user?.role?._id
|
let roleId = ctx.user?.role?._id
|
||||||
const roleIds = (await roles.getUserRoleHierarchy(roleId, {
|
const roleIds = (await roles.getUserRoleHierarchy(roleId, {
|
||||||
|
|
|
@ -96,7 +96,7 @@ export default async (ctx: UserCtx, next: any) => {
|
||||||
const userId = ctx.user
|
const userId = ctx.user
|
||||||
? generateUserMetadataID(ctx.user._id!)
|
? generateUserMetadataID(ctx.user._id!)
|
||||||
: undefined
|
: undefined
|
||||||
let role = (ctx.user = {
|
ctx.user = {
|
||||||
...ctx.user!,
|
...ctx.user!,
|
||||||
// override userID with metadata one
|
// override userID with metadata one
|
||||||
_id: userId,
|
_id: userId,
|
||||||
|
@ -104,7 +104,7 @@ export default async (ctx: UserCtx, next: any) => {
|
||||||
globalId,
|
globalId,
|
||||||
roleId,
|
roleId,
|
||||||
role: await roles.getRole(roleId, { defaultPublic: true }),
|
role: await roles.getRole(roleId, { defaultPublic: true }),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return next()
|
return next()
|
||||||
|
|
Loading…
Reference in New Issue