@budibase/worker 1.1.33-alpha.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"author": "Budibase",
|
|
36
36
|
"license": "GPL-3.0",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@budibase/backend-core": "1.
|
|
39
|
-
"@budibase/pro": "1.
|
|
40
|
-
"@budibase/string-templates": "1.
|
|
41
|
-
"@budibase/types": "1.
|
|
38
|
+
"@budibase/backend-core": "^1.2.4",
|
|
39
|
+
"@budibase/pro": "1.2.3",
|
|
40
|
+
"@budibase/string-templates": "^1.2.4",
|
|
41
|
+
"@budibase/types": "^1.2.4",
|
|
42
42
|
"@koa/router": "8.0.8",
|
|
43
43
|
"@sentry/node": "6.17.7",
|
|
44
44
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"./scripts/jestSetup.js"
|
|
102
102
|
]
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "0995a35ea32820b60ea6dccca2561401a0a137ea"
|
|
105
105
|
}
|
|
@@ -3,17 +3,18 @@ import { checkInviteCode } from "../../../utilities/redis"
|
|
|
3
3
|
import { sendEmail } from "../../../utilities/email"
|
|
4
4
|
import { users } from "../../../sdk"
|
|
5
5
|
import env from "../../../environment"
|
|
6
|
-
import {
|
|
6
|
+
import { CloudAccount, User } from "@budibase/types"
|
|
7
7
|
import {
|
|
8
|
-
events,
|
|
9
|
-
errors,
|
|
10
8
|
accounts,
|
|
11
|
-
users as usersCore,
|
|
12
|
-
tenancy,
|
|
13
9
|
cache,
|
|
10
|
+
errors,
|
|
11
|
+
events,
|
|
12
|
+
tenancy,
|
|
13
|
+
users as usersCore,
|
|
14
14
|
} from "@budibase/backend-core"
|
|
15
15
|
import { checkAnyUserExists } from "../../../utilities/users"
|
|
16
16
|
import { groups as groupUtils } from "@budibase/pro"
|
|
17
|
+
|
|
17
18
|
const MAX_USERS_UPLOAD_LIMIT = 1000
|
|
18
19
|
|
|
19
20
|
export const save = async (ctx: any) => {
|
|
@@ -117,8 +118,7 @@ export const adminUser = async (ctx: any) => {
|
|
|
117
118
|
export const countByApp = async (ctx: any) => {
|
|
118
119
|
const appId = ctx.params.appId
|
|
119
120
|
try {
|
|
120
|
-
|
|
121
|
-
ctx.body = response
|
|
121
|
+
ctx.body = await users.countUsersByApp(appId)
|
|
122
122
|
} catch (err: any) {
|
|
123
123
|
ctx.throw(err.status || 400, err)
|
|
124
124
|
}
|
|
@@ -126,6 +126,9 @@ export const countByApp = async (ctx: any) => {
|
|
|
126
126
|
|
|
127
127
|
export const destroy = async (ctx: any) => {
|
|
128
128
|
const id = ctx.params.id
|
|
129
|
+
if (id === ctx.user._id) {
|
|
130
|
+
ctx.throw(400, "Unable to delete self.")
|
|
131
|
+
}
|
|
129
132
|
|
|
130
133
|
await users.destroy(id, ctx.user)
|
|
131
134
|
|
|
@@ -136,6 +139,10 @@ export const destroy = async (ctx: any) => {
|
|
|
136
139
|
|
|
137
140
|
export const bulkDelete = async (ctx: any) => {
|
|
138
141
|
const { userIds } = ctx.request.body
|
|
142
|
+
if (userIds?.indexOf(ctx.user._id) !== -1) {
|
|
143
|
+
ctx.throw(400, "Unable to delete self.")
|
|
144
|
+
}
|
|
145
|
+
|
|
139
146
|
try {
|
|
140
147
|
let usersResponse = await users.bulkDelete(userIds)
|
|
141
148
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const Joi = require("joi")
|
|
2
|
-
|
|
3
1
|
function validate(schema, property) {
|
|
4
2
|
// Return a Koa middleware function
|
|
5
3
|
return (ctx, next) => {
|
|
@@ -12,12 +10,6 @@ function validate(schema, property) {
|
|
|
12
10
|
} else if (ctx.request[property] != null) {
|
|
13
11
|
params = ctx.request[property]
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
schema = schema.append({
|
|
17
|
-
createdAt: Joi.any().optional(),
|
|
18
|
-
updatedAt: Joi.any().optional(),
|
|
19
|
-
})
|
|
20
|
-
|
|
21
13
|
const { error } = schema.validate(params)
|
|
22
14
|
if (error) {
|
|
23
15
|
ctx.throw(400, `Invalid ${property} - ${error.message}`)
|