2023-07-18 17:57:48 +02:00
|
|
|
import { UserCtx } from "@budibase/types"
|
|
|
|
import { isBuilder, isAdmin } from "../users"
|
|
|
|
import { getAppId } from "../context"
|
2022-11-24 19:48:51 +01:00
|
|
|
|
2023-07-18 17:57:48 +02:00
|
|
|
export default async (ctx: UserCtx, next: any) => {
|
|
|
|
const appId = getAppId()
|
|
|
|
if (!ctx.internal && !isBuilder(ctx.user, appId) && !isAdmin(ctx.user)) {
|
|
|
|
ctx.throw(403, "Admin/Builder user only endpoint.")
|
2022-06-01 16:20:56 +02:00
|
|
|
}
|
|
|
|
return next()
|
|
|
|
}
|