Adding pro integration.
This commit is contained in:
parent
92dd5f1d85
commit
b3e8989060
|
@ -1 +1 @@
|
||||||
Subproject commit 9b9c8cc08f271bfc5dd401860f344f6eb336ab35
|
Subproject commit bf719cb968a13183225696a74fb40a78668a54a6
|
|
@ -57,6 +57,40 @@ const userSchema = object(
|
||||||
"If set to true forces the user to reset their password on first login.",
|
"If set to true forces the user to reset their password on first login.",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
},
|
},
|
||||||
|
builder: {
|
||||||
|
description:
|
||||||
|
"Describes if the user is a builder user or not. This field can only be set on a business or enterprise license.",
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
global: {
|
||||||
|
description:
|
||||||
|
"If set to true the user will be able to build any app in the system.",
|
||||||
|
type: "boolean",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"Describes if the user is an admin user or not. This field can only be set on a business or enterprise license.",
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
global: {
|
||||||
|
description:
|
||||||
|
"If set to true the user will be able to administrate the system.",
|
||||||
|
type: "boolean",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
roles: {
|
||||||
|
description:
|
||||||
|
"Contains the roles of the user per app (assuming they are not a builder user). This field can only be set on a business or enterprise license.",
|
||||||
|
type: "object",
|
||||||
|
additionalProperties: {
|
||||||
|
type: "string",
|
||||||
|
description:
|
||||||
|
"A map of app ID (production app ID, minus the _dev component) to a role ID, e.g. ADMIN.",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ required: ["email", "roles"] }
|
{ required: ["email", "roles"] }
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,21 +9,7 @@ import { db as dbCore } from "@budibase/backend-core"
|
||||||
import { search as stringSearch } from "./utils"
|
import { search as stringSearch } from "./utils"
|
||||||
import { UserCtx, User } from "@budibase/types"
|
import { UserCtx, User } from "@budibase/types"
|
||||||
import { Next } from "koa"
|
import { Next } from "koa"
|
||||||
|
import { sdk } from "@budibase/pro"
|
||||||
function removeRoles(ctx: UserCtx, oldUser?: User) {
|
|
||||||
const user = ctx.request.body
|
|
||||||
if (user.builder) {
|
|
||||||
user.builder = oldUser?.builder || undefined
|
|
||||||
}
|
|
||||||
if (user.admin) {
|
|
||||||
user.admin = oldUser?.admin || undefined
|
|
||||||
}
|
|
||||||
if (user.roles) {
|
|
||||||
user.roles = oldUser?.roles || {}
|
|
||||||
}
|
|
||||||
ctx.request.body = user
|
|
||||||
return ctx
|
|
||||||
}
|
|
||||||
|
|
||||||
function isLoggedInUser(ctx: UserCtx, user: User) {
|
function isLoggedInUser(ctx: UserCtx, user: User) {
|
||||||
const loggedInId = ctx.user?._id
|
const loggedInId = ctx.user?._id
|
||||||
|
@ -49,7 +35,7 @@ export async function search(ctx: UserCtx, next: Next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function create(ctx: UserCtx, next: Next) {
|
export async function create(ctx: UserCtx, next: Next) {
|
||||||
ctx = publicApiUserFix(removeRoles(ctx))
|
ctx = publicApiUserFix(await sdk.publicApi.userSaveUpdate(ctx))
|
||||||
const response = await saveGlobalUser(ctx)
|
const response = await saveGlobalUser(ctx)
|
||||||
ctx.body = await getUser(ctx, response._id)
|
ctx.body = await getUser(ctx, response._id)
|
||||||
await next()
|
await next()
|
||||||
|
@ -66,7 +52,7 @@ export async function update(ctx: UserCtx, next: Next) {
|
||||||
...ctx.request.body,
|
...ctx.request.body,
|
||||||
_rev: user._rev,
|
_rev: user._rev,
|
||||||
}
|
}
|
||||||
ctx = publicApiUserFix(removeRoles(ctx, user))
|
ctx = publicApiUserFix(await sdk.publicApi.userSaveUpdate(ctx, user))
|
||||||
const response = await saveGlobalUser(ctx)
|
const response = await saveGlobalUser(ctx)
|
||||||
ctx.body = await getUser(ctx, response._id)
|
ctx.body = await getUser(ctx, response._id)
|
||||||
await next()
|
await next()
|
||||||
|
|
|
@ -11,6 +11,7 @@ export enum Feature {
|
||||||
SYNC_AUTOMATIONS = "syncAutomations",
|
SYNC_AUTOMATIONS = "syncAutomations",
|
||||||
APP_BUILDERS = "appBuilders",
|
APP_BUILDERS = "appBuilders",
|
||||||
OFFLINE = "offline",
|
OFFLINE = "offline",
|
||||||
|
USER_ROLE_PUBLIC_API = "userRolePublicApi",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PlanFeatures = { [key in PlanType]: Feature[] | undefined }
|
export type PlanFeatures = { [key in PlanType]: Feature[] | undefined }
|
||||||
|
|
Loading…
Reference in New Issue