Some type updates and fixes for test case.

This commit is contained in:
mike12345567 2023-06-13 14:45:33 +01:00
parent bedc8e5cce
commit 1bdf55e966
3 changed files with 6 additions and 6 deletions

View File

@ -165,7 +165,7 @@ export async function getRole(
// finalise the ID
role._id = getExternalRoleID(role._id)
} catch (err) {
if (opts?.defaultPublic) {
if (!isBuiltin(roleId) && opts?.defaultPublic) {
return cloneDeep(BUILTIN_ROLES.PUBLIC)
}
// only throw an error if there is no role at all

View File

@ -1,6 +1,6 @@
import { getRoutingInfo } from "../../utilities/routing"
import { roles } from "@budibase/backend-core"
import { BBContext } from "@budibase/types"
import { UserCtx } from "@budibase/types"
const URL_SEPARATOR = "/"
@ -56,11 +56,11 @@ async function getRoutingStructure() {
return { routes: routing.json }
}
export async function fetch(ctx: BBContext) {
export async function fetch(ctx: UserCtx) {
ctx.body = await getRoutingStructure()
}
export async function clientFetch(ctx: BBContext) {
export async function clientFetch(ctx: UserCtx) {
const routing = await getRoutingStructure()
let roleId = ctx.user?.role?._id
const roleIds = (await roles.getUserRoleHierarchy(roleId, {

View File

@ -96,7 +96,7 @@ export default async (ctx: UserCtx, next: any) => {
const userId = ctx.user
? generateUserMetadataID(ctx.user._id!)
: undefined
let role = (ctx.user = {
ctx.user = {
...ctx.user!,
// override userID with metadata one
_id: userId,
@ -104,7 +104,7 @@ export default async (ctx: UserCtx, next: any) => {
globalId,
roleId,
role: await roles.getRole(roleId, { defaultPublic: true }),
})
}
}
return next()