@budibase/worker 2.14.6 → 2.14.8
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.14.
|
|
4
|
+
"version": "2.14.8",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"author": "Budibase",
|
|
38
38
|
"license": "GPL-3.0",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@budibase/backend-core": "2.14.
|
|
41
|
-
"@budibase/pro": "2.14.
|
|
42
|
-
"@budibase/string-templates": "2.14.
|
|
43
|
-
"@budibase/types": "2.14.
|
|
40
|
+
"@budibase/backend-core": "2.14.8",
|
|
41
|
+
"@budibase/pro": "2.14.8",
|
|
42
|
+
"@budibase/string-templates": "2.14.8",
|
|
43
|
+
"@budibase/types": "2.14.8",
|
|
44
44
|
"@koa/router": "8.0.8",
|
|
45
45
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
46
46
|
"@types/global-agent": "2.1.1",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "a301869275af8c21c8fc69203a75725fa88ecce1"
|
|
110
110
|
}
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
InviteUserRequest,
|
|
13
13
|
InviteUsersRequest,
|
|
14
14
|
InviteUsersResponse,
|
|
15
|
+
LockName,
|
|
16
|
+
LockType,
|
|
15
17
|
MigrationType,
|
|
16
18
|
SaveUserResponse,
|
|
17
19
|
SearchUsersRequest,
|
|
@@ -27,6 +29,7 @@ import {
|
|
|
27
29
|
platform,
|
|
28
30
|
tenancy,
|
|
29
31
|
db,
|
|
32
|
+
locks,
|
|
30
33
|
} from "@budibase/backend-core"
|
|
31
34
|
import { checkAnyUserExists } from "../../../utilities/users"
|
|
32
35
|
import { isEmailConfigured } from "../../../utilities/email"
|
|
@@ -380,51 +383,60 @@ export const inviteAccept = async (
|
|
|
380
383
|
) => {
|
|
381
384
|
const { inviteCode, password, firstName, lastName } = ctx.request.body
|
|
382
385
|
try {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
386
|
+
await locks.doWithLock(
|
|
387
|
+
{
|
|
388
|
+
type: LockType.AUTO_EXTEND,
|
|
389
|
+
name: LockName.PROCESS_USER_INVITE,
|
|
390
|
+
resource: inviteCode,
|
|
391
|
+
systemLock: true,
|
|
392
|
+
},
|
|
393
|
+
async () => {
|
|
394
|
+
// info is an extension of the user object that was stored by global
|
|
395
|
+
const { email, info } = await cache.invite.getCode(inviteCode)
|
|
396
|
+
const user = await tenancy.doInTenant(info.tenantId, async () => {
|
|
397
|
+
let request: any = {
|
|
398
|
+
firstName,
|
|
399
|
+
lastName,
|
|
400
|
+
password,
|
|
401
|
+
email,
|
|
402
|
+
admin: { global: info?.admin?.global || false },
|
|
403
|
+
roles: info.apps,
|
|
404
|
+
tenantId: info.tenantId,
|
|
405
|
+
}
|
|
406
|
+
const builder: { global: boolean; apps?: string[] } = {
|
|
407
|
+
global: info?.builder?.global || false,
|
|
408
|
+
}
|
|
399
409
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
410
|
+
if (info?.builder?.apps) {
|
|
411
|
+
builder.apps = info.builder.apps
|
|
412
|
+
request.builder = builder
|
|
413
|
+
}
|
|
414
|
+
delete info.apps
|
|
415
|
+
request = {
|
|
416
|
+
...request,
|
|
417
|
+
...info,
|
|
418
|
+
}
|
|
409
419
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return saved
|
|
415
|
-
})
|
|
420
|
+
const saved = await userSdk.db.save(request)
|
|
421
|
+
await events.user.inviteAccepted(saved)
|
|
422
|
+
return saved
|
|
423
|
+
})
|
|
416
424
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
425
|
+
await cache.invite.deleteCode(inviteCode)
|
|
426
|
+
|
|
427
|
+
ctx.body = {
|
|
428
|
+
_id: user._id!,
|
|
429
|
+
_rev: user._rev!,
|
|
430
|
+
email: user.email,
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
)
|
|
422
434
|
} catch (err: any) {
|
|
423
435
|
if (err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) {
|
|
424
436
|
// explicitly re-throw limit exceeded errors
|
|
425
437
|
ctx.throw(400, err)
|
|
426
438
|
}
|
|
427
439
|
console.warn("Error inviting user", err)
|
|
428
|
-
ctx.throw(400, "Unable to create new user, invitation invalid.")
|
|
440
|
+
ctx.throw(400, err || "Unable to create new user, invitation invalid.")
|
|
429
441
|
}
|
|
430
442
|
}
|