@budibase/worker 1.3.5 → 1.3.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 +6 -6
- package/src/sdk/users/users.ts +18 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.8",
|
|
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.3.
|
|
39
|
-
"@budibase/pro": "1.3.
|
|
40
|
-
"@budibase/string-templates": "^1.3.
|
|
41
|
-
"@budibase/types": "^1.3.
|
|
38
|
+
"@budibase/backend-core": "^1.3.8",
|
|
39
|
+
"@budibase/pro": "1.3.7",
|
|
40
|
+
"@budibase/string-templates": "^1.3.8",
|
|
41
|
+
"@budibase/types": "^1.3.8",
|
|
42
42
|
"@koa/router": "8.0.8",
|
|
43
43
|
"@sentry/node": "6.17.7",
|
|
44
44
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"./scripts/jestSetup.js"
|
|
104
104
|
]
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "1142dff43086090a96ade22cdad43d0a8ace988a"
|
|
107
107
|
}
|
package/src/sdk/users/users.ts
CHANGED
|
@@ -189,23 +189,34 @@ export const save = async (
|
|
|
189
189
|
const tenantId = tenancy.getTenantId()
|
|
190
190
|
const db = tenancy.getGlobalDB()
|
|
191
191
|
let { email, _id } = user
|
|
192
|
+
if (!email && !_id) {
|
|
193
|
+
throw new Error("_id or email is required")
|
|
194
|
+
}
|
|
192
195
|
|
|
193
196
|
let dbUser: User | undefined
|
|
194
197
|
if (_id) {
|
|
195
198
|
// try to get existing user from db
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
try {
|
|
200
|
+
dbUser = (await db.get(_id)) as User
|
|
201
|
+
if (email && dbUser.email !== email) {
|
|
202
|
+
throw "Email address cannot be changed"
|
|
203
|
+
}
|
|
204
|
+
email = dbUser.email
|
|
205
|
+
} catch (e: any) {
|
|
206
|
+
if (e.status === 404) {
|
|
207
|
+
// do nothing, save this new user with the id specified - required for SSO auth
|
|
208
|
+
} else {
|
|
209
|
+
throw e
|
|
210
|
+
}
|
|
199
211
|
}
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (!dbUser && email) {
|
|
202
215
|
// no id was specified - load from email instead
|
|
203
216
|
dbUser = await usersCore.getGlobalUserByEmail(email)
|
|
204
217
|
if (dbUser && dbUser._id !== _id) {
|
|
205
218
|
throw `Unavailable`
|
|
206
219
|
}
|
|
207
|
-
} else {
|
|
208
|
-
throw new Error("_id or email is required")
|
|
209
220
|
}
|
|
210
221
|
|
|
211
222
|
await validateUniqueUser(email, tenantId)
|