@budibase/worker 2.1.11 → 2.1.12

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": "2.1.11",
4
+ "version": "2.1.12",
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.11",
40
- "@budibase/pro": "2.1.10",
41
- "@budibase/string-templates": "^2.1.11",
42
- "@budibase/types": "^2.1.11",
39
+ "@budibase/backend-core": "^2.1.12",
40
+ "@budibase/pro": "2.1.11",
41
+ "@budibase/string-templates": "^2.1.12",
42
+ "@budibase/types": "^2.1.12",
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": "8e99104f2f912e4405ccf8f3e6554df23d04d376"
107
+ "gitHead": "d9cf2a8e197aee35b0ffaf16e8c8988f63a571f0"
108
108
  }
@@ -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
- let { email, _id } = user
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,