@budibase/worker 1.0.185 → 1.0.186
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.0.
|
|
4
|
+
"version": "1.0.186",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"author": "Budibase",
|
|
33
33
|
"license": "GPL-3.0",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@budibase/backend-core": "^1.0.
|
|
36
|
-
"@budibase/pro": "1.0.
|
|
37
|
-
"@budibase/string-templates": "^1.0.
|
|
35
|
+
"@budibase/backend-core": "^1.0.186",
|
|
36
|
+
"@budibase/pro": "1.0.185",
|
|
37
|
+
"@budibase/string-templates": "^1.0.186",
|
|
38
38
|
"@koa/router": "^8.0.0",
|
|
39
39
|
"@sentry/node": "6.17.7",
|
|
40
40
|
"@techpass/passport-openidconnect": "^0.3.0",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"./scripts/jestSetup.js"
|
|
91
91
|
]
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "4ecd3e9454ffd139a893e3d92af3dc0a3b736b07"
|
|
94
94
|
}
|
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
getTenantId,
|
|
13
13
|
getTenantUser,
|
|
14
14
|
doesTenantExist,
|
|
15
|
+
doInTenant,
|
|
15
16
|
} = require("@budibase/backend-core/tenancy")
|
|
16
17
|
const { removeUserFromInfoDB } = require("@budibase/backend-core/deprovision")
|
|
17
18
|
const { errors } = require("@budibase/backend-core")
|
|
@@ -41,70 +42,73 @@ const parseBooleanParam = (param: any) => {
|
|
|
41
42
|
|
|
42
43
|
export const adminUser = async (ctx: any) => {
|
|
43
44
|
const { email, password, tenantId } = ctx.request.body
|
|
45
|
+
await doInTenant(tenantId, async () => {
|
|
46
|
+
// account portal sends a pre-hashed password - honour param to prevent double hashing
|
|
47
|
+
const hashPassword = parseBooleanParam(ctx.request.query.hashPassword)
|
|
48
|
+
// account portal sends no password for SSO users
|
|
49
|
+
const requirePassword = parseBooleanParam(ctx.request.query.requirePassword)
|
|
50
|
+
|
|
51
|
+
if (await doesTenantExist(tenantId)) {
|
|
52
|
+
ctx.throw(403, "Organisation already exists.")
|
|
53
|
+
}
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
const usageQuota = await db.get(StaticDatabases.GLOBAL.docs.usageQuota)
|
|
65
|
-
if (usageQuota) {
|
|
66
|
-
await db.remove(usageQuota._id, usageQuota._rev)
|
|
55
|
+
const response = await doWithGlobalDB(tenantId, async (db: any) => {
|
|
56
|
+
const response = await db.allDocs(
|
|
57
|
+
getGlobalUserParams(null, {
|
|
58
|
+
include_docs: true,
|
|
59
|
+
})
|
|
60
|
+
)
|
|
61
|
+
// write usage quotas for cloud
|
|
62
|
+
if (!env.SELF_HOSTED) {
|
|
63
|
+
// could be a scenario where it exists, make sure its clean
|
|
64
|
+
try {
|
|
65
|
+
const usageQuota = await db.get(
|
|
66
|
+
StaticDatabases.GLOBAL.docs.usageQuota
|
|
67
|
+
)
|
|
68
|
+
if (usageQuota) {
|
|
69
|
+
await db.remove(usageQuota._id, usageQuota._rev)
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
// don't worry about errors
|
|
67
73
|
}
|
|
68
|
-
|
|
69
|
-
// don't worry about errors
|
|
74
|
+
await db.put(quotas.generateNewQuotaUsage())
|
|
70
75
|
}
|
|
71
|
-
|
|
76
|
+
return response
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
if (response.rows.some((row: any) => row.doc.admin)) {
|
|
80
|
+
ctx.throw(
|
|
81
|
+
403,
|
|
82
|
+
"You cannot initialise once an global user has been created."
|
|
83
|
+
)
|
|
72
84
|
}
|
|
73
|
-
return response
|
|
74
|
-
})
|
|
75
85
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
roles: {},
|
|
88
|
-
builder: {
|
|
89
|
-
global: true,
|
|
90
|
-
},
|
|
91
|
-
admin: {
|
|
92
|
-
global: true,
|
|
93
|
-
},
|
|
94
|
-
tenantId,
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
const finalUser = await users.save(
|
|
98
|
-
user,
|
|
86
|
+
const user = {
|
|
87
|
+
email: email,
|
|
88
|
+
password: password,
|
|
89
|
+
createdAt: Date.now(),
|
|
90
|
+
roles: {},
|
|
91
|
+
builder: {
|
|
92
|
+
global: true,
|
|
93
|
+
},
|
|
94
|
+
admin: {
|
|
95
|
+
global: true,
|
|
96
|
+
},
|
|
99
97
|
tenantId,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const finalUser = await users.save(
|
|
101
|
+
user,
|
|
102
|
+
tenantId,
|
|
103
|
+
hashPassword,
|
|
104
|
+
requirePassword
|
|
105
|
+
)
|
|
106
|
+
await bustCache(CacheKeys.CHECKLIST)
|
|
107
|
+
ctx.body = finalUser
|
|
108
|
+
} catch (err: any) {
|
|
109
|
+
ctx.throw(err.status || 400, err)
|
|
110
|
+
}
|
|
111
|
+
})
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
export const destroy = async (ctx: any) => {
|