@budibase/worker 2.1.12-alpha.0 → 2.1.13
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 +6 -6
- package/src/sdk/users/users.ts +13 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.13",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"author": "Budibase",
|
|
37
37
|
"license": "GPL-3.0",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@budibase/backend-core": "2.1.
|
|
40
|
-
"@budibase/pro": "2.1.
|
|
41
|
-
"@budibase/string-templates": "2.1.
|
|
42
|
-
"@budibase/types": "2.1.
|
|
39
|
+
"@budibase/backend-core": "^2.1.13",
|
|
40
|
+
"@budibase/pro": "2.1.12",
|
|
41
|
+
"@budibase/string-templates": "^2.1.13",
|
|
42
|
+
"@budibase/types": "^2.1.13",
|
|
43
43
|
"@koa/router": "8.0.8",
|
|
44
44
|
"@sentry/node": "6.17.7",
|
|
45
45
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"./scripts/jestSetup.js"
|
|
105
105
|
]
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "6c352980b58e606f88d73a730b20f599ebd0f64d"
|
|
108
108
|
}
|
package/src/sdk/users/users.ts
CHANGED
|
@@ -177,7 +177,9 @@ export const save = async (
|
|
|
177
177
|
): Promise<CreateUserResponse> => {
|
|
178
178
|
const tenantId = tenancy.getTenantId()
|
|
179
179
|
const db = tenancy.getGlobalDB()
|
|
180
|
-
|
|
180
|
+
|
|
181
|
+
let { email, _id, userGroups = [] } = user
|
|
182
|
+
|
|
181
183
|
if (!email && !_id) {
|
|
182
184
|
throw new Error("_id or email is required")
|
|
183
185
|
}
|
|
@@ -213,8 +215,16 @@ export const save = async (
|
|
|
213
215
|
let builtUser = await buildUser(user, opts, tenantId, dbUser)
|
|
214
216
|
|
|
215
217
|
// make sure we set the _id field for a new user
|
|
218
|
+
// Also if this is a new user, associate groups with them
|
|
219
|
+
let groupPromises = []
|
|
216
220
|
if (!_id) {
|
|
217
221
|
_id = builtUser._id!
|
|
222
|
+
|
|
223
|
+
if (userGroups.length > 0) {
|
|
224
|
+
for (let groupId of userGroups) {
|
|
225
|
+
groupPromises.push(groupsSdk.addUsers(groupId, [_id]))
|
|
226
|
+
}
|
|
227
|
+
}
|
|
218
228
|
}
|
|
219
229
|
|
|
220
230
|
try {
|
|
@@ -228,6 +238,8 @@ export const save = async (
|
|
|
228
238
|
// let server know to sync user
|
|
229
239
|
await apps.syncUserInApps(_id)
|
|
230
240
|
|
|
241
|
+
await Promise.all(groupPromises)
|
|
242
|
+
|
|
231
243
|
return {
|
|
232
244
|
_id: response.id,
|
|
233
245
|
_rev: response.rev,
|