budibase/packages/backend-core/src/middleware/builderOrAdmin.ts

13 lines
328 B
TypeScript
Raw Normal View History

import { BBContext } from "@budibase/types"
export = async (ctx: BBContext, next: any) => {
2022-06-01 16:20:56 +02:00
if (
!ctx.internal &&
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global) &&
(!ctx.user || !ctx.user.admin || !ctx.user.admin.global)
) {
ctx.throw(403, "Builder user only endpoint.")
}
return next()
}