Merge branch 'master' of github.com:Budibase/budibase into develop
This commit is contained in:
commit
b36702ca72
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"packages": ["packages/*"],
|
"packages": ["packages/*"],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/backend-core",
|
"name": "@budibase/backend-core",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Budibase backend core libraries used in server and worker",
|
"description": "Budibase backend core libraries used in server and worker",
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/src/index.js",
|
||||||
"types": "dist/src/index.d.ts",
|
"types": "dist/src/index.d.ts",
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/nano": "10.1.2",
|
"@budibase/nano": "10.1.2",
|
||||||
"@budibase/pouchdb-replication-stream": "1.2.10",
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
||||||
"@budibase/types": "2.4.44-alpha.26",
|
"@budibase/types": "^2.5.4",
|
||||||
"@shopify/jest-koa-mocks": "5.0.1",
|
"@shopify/jest-koa-mocks": "5.0.1",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
"aws-cloudfront-sign": "2.2.0",
|
"aws-cloudfront-sign": "2.2.0",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/bbui",
|
"name": "@budibase/bbui",
|
||||||
"description": "A UI solution used in the different Budibase projects.",
|
"description": "A UI solution used in the different Budibase projects.",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"module": "dist/bbui.es.js",
|
"module": "dist/bbui.es.js",
|
||||||
|
@ -38,8 +38,8 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adobe/spectrum-css-workflow-icons": "1.2.1",
|
"@adobe/spectrum-css-workflow-icons": "1.2.1",
|
||||||
"@budibase/shared-core": "2.4.44-alpha.26",
|
"@budibase/shared-core": "^2.5.4",
|
||||||
"@budibase/string-templates": "2.4.44-alpha.26",
|
"@budibase/string-templates": "^2.5.4",
|
||||||
"@spectrum-css/accordion": "3.0.24",
|
"@spectrum-css/accordion": "3.0.24",
|
||||||
"@spectrum-css/actionbutton": "1.0.1",
|
"@spectrum-css/actionbutton": "1.0.1",
|
||||||
"@spectrum-css/actiongroup": "1.0.1",
|
"@spectrum-css/actiongroup": "1.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/builder",
|
"name": "@budibase/builder",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -58,11 +58,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "2.4.44-alpha.26",
|
"@budibase/bbui": "^2.5.4",
|
||||||
"@budibase/client": "2.4.44-alpha.26",
|
"@budibase/client": "^2.5.4",
|
||||||
"@budibase/frontend-core": "2.4.44-alpha.26",
|
"@budibase/frontend-core": "^2.5.4",
|
||||||
"@budibase/shared-core": "2.4.44-alpha.26",
|
"@budibase/shared-core": "^2.5.4",
|
||||||
"@budibase/string-templates": "2.4.44-alpha.26",
|
"@budibase/string-templates": "^2.5.4",
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
||||||
"@fortawesome/free-brands-svg-icons": "^6.2.1",
|
"@fortawesome/free-brands-svg-icons": "^6.2.1",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.2.1",
|
"@fortawesome/free-solid-svg-icons": "^6.2.1",
|
||||||
|
|
|
@ -120,7 +120,7 @@ export const toBindingsArray = (valueMap, prefix, category) => {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return Object.keys(valueMap).reduce((acc, binding) => {
|
return Object.keys(valueMap).reduce((acc, binding) => {
|
||||||
if (!binding || !valueMap[binding]) {
|
if (!binding) {
|
||||||
return acc
|
return acc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,13 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if type === "options" && meta.constraints.inclusion.length !== 0}
|
{#if type === "options" && meta.constraints.inclusion.length !== 0}
|
||||||
<Select {label} bind:value options={meta.constraints.inclusion} sort />
|
<Select
|
||||||
|
{label}
|
||||||
|
bind:value
|
||||||
|
options={meta.constraints.inclusion}
|
||||||
|
sort
|
||||||
|
{error}
|
||||||
|
/>
|
||||||
{:else if type === "datetime"}
|
{:else if type === "datetime"}
|
||||||
<DatePicker
|
<DatePicker
|
||||||
{error}
|
{error}
|
||||||
|
|
|
@ -27,21 +27,19 @@
|
||||||
notifications.success("Row saved successfully")
|
notifications.success("Row saved successfully")
|
||||||
dispatch("updaterows")
|
dispatch("updaterows")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.handled) {
|
const response = error.json
|
||||||
const response = error.json
|
if (error.handled && response?.errors) {
|
||||||
if (response?.errors) {
|
errors = response.errors
|
||||||
errors = response.errors
|
} else if (error.handled && response?.validationErrors) {
|
||||||
} else if (response?.validationErrors) {
|
const mappedErrors = {}
|
||||||
const mappedErrors = {}
|
for (let field in response.validationErrors) {
|
||||||
for (let field in response.validationErrors) {
|
mappedErrors[
|
||||||
mappedErrors[
|
field
|
||||||
field
|
] = `${field} ${response.validationErrors[field][0]}`
|
||||||
] = `${field} ${response.validationErrors[field][0]}`
|
|
||||||
}
|
|
||||||
errors = mappedErrors
|
|
||||||
}
|
}
|
||||||
|
errors = mappedErrors
|
||||||
} else {
|
} else {
|
||||||
notifications.error("Failed to save row")
|
notifications.error(`Failed to save row - ${error.message}`)
|
||||||
}
|
}
|
||||||
// Prevent modal closing if there were errors
|
// Prevent modal closing if there were errors
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/cli",
|
"name": "@budibase/cli",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -29,9 +29,9 @@
|
||||||
"outputPath": "build"
|
"outputPath": "build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "2.4.44-alpha.26",
|
"@budibase/backend-core": "^2.5.4",
|
||||||
"@budibase/string-templates": "2.4.44-alpha.26",
|
"@budibase/string-templates": "^2.5.4",
|
||||||
"@budibase/types": "2.4.44-alpha.26",
|
"@budibase/types": "^2.5.4",
|
||||||
"axios": "0.21.2",
|
"axios": "0.21.2",
|
||||||
"chalk": "4.1.0",
|
"chalk": "4.1.0",
|
||||||
"cli-progress": "3.11.2",
|
"cli-progress": "3.11.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/client",
|
"name": "@budibase/client",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"module": "dist/budibase-client.js",
|
"module": "dist/budibase-client.js",
|
||||||
"main": "dist/budibase-client.js",
|
"main": "dist/budibase-client.js",
|
||||||
|
@ -19,11 +19,11 @@
|
||||||
"dev:builder": "rollup -cw"
|
"dev:builder": "rollup -cw"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "2.4.44-alpha.26",
|
"@budibase/bbui": "^2.5.4",
|
||||||
"@budibase/frontend-core": "2.4.44-alpha.26",
|
"@budibase/frontend-core": "^2.5.4",
|
||||||
"@budibase/shared-core": "2.4.44-alpha.26",
|
"@budibase/shared-core": "^2.5.4",
|
||||||
"@budibase/string-templates": "2.4.44-alpha.26",
|
"@budibase/string-templates": "^2.5.4",
|
||||||
"@budibase/types": "2.4.44-alpha.26",
|
"@budibase/types": "^2.5.4",
|
||||||
"@spectrum-css/button": "^3.0.3",
|
"@spectrum-css/button": "^3.0.3",
|
||||||
"@spectrum-css/card": "^3.0.3",
|
"@spectrum-css/card": "^3.0.3",
|
||||||
"@spectrum-css/divider": "^1.0.3",
|
"@spectrum-css/divider": "^1.0.3",
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/frontend-core",
|
"name": "@budibase/frontend-core",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Budibase frontend core libraries used in builder and client",
|
"description": "Budibase frontend core libraries used in builder and client",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"svelte": "src/index.js",
|
"svelte": "src/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/bbui": "2.4.44-alpha.26",
|
"@budibase/bbui": "^2.5.4",
|
||||||
"@budibase/shared-core": "2.4.44-alpha.26",
|
"@budibase/shared-core": "^2.5.4",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"svelte": "^3.46.2"
|
"svelte": "^3.46.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/sdk",
|
"name": "@budibase/sdk",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Budibase Public API SDK",
|
"description": "Budibase Public API SDK",
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/server",
|
"name": "@budibase/server",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Budibase Web Server",
|
"description": "Budibase Web Server",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -45,12 +45,12 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/swagger-parser": "10.0.3",
|
"@apidevtools/swagger-parser": "10.0.3",
|
||||||
"@budibase/backend-core": "2.4.44-alpha.26",
|
"@budibase/backend-core": "^2.5.4",
|
||||||
"@budibase/client": "2.4.44-alpha.26",
|
"@budibase/client": "^2.5.4",
|
||||||
"@budibase/pro": "2.4.44-alpha.26",
|
"@budibase/pro": "2.5.4",
|
||||||
"@budibase/shared-core": "2.4.44-alpha.26",
|
"@budibase/shared-core": "^2.5.4",
|
||||||
"@budibase/string-templates": "2.4.44-alpha.26",
|
"@budibase/string-templates": "^2.5.4",
|
||||||
"@budibase/types": "2.4.44-alpha.26",
|
"@budibase/types": "^2.5.4",
|
||||||
"@bull-board/api": "3.7.0",
|
"@bull-board/api": "3.7.0",
|
||||||
"@bull-board/koa": "3.9.4",
|
"@bull-board/koa": "3.9.4",
|
||||||
"@elastic/elasticsearch": "7.10.0",
|
"@elastic/elasticsearch": "7.10.0",
|
||||||
|
@ -115,7 +115,11 @@
|
||||||
"to-json-schema": "0.2.5",
|
"to-json-schema": "0.2.5",
|
||||||
"uuid": "3.3.2",
|
"uuid": "3.3.2",
|
||||||
"validate.js": "0.13.1",
|
"validate.js": "0.13.1",
|
||||||
|
<<<<<<< HEAD
|
||||||
"vm2": "3.9.16",
|
"vm2": "3.9.16",
|
||||||
|
=======
|
||||||
|
"vm2": "^3.9.15",
|
||||||
|
>>>>>>> f45da9ccfde1fedb83ec757e64fb972b510c67d6
|
||||||
"worker-farm": "1.7.0",
|
"worker-farm": "1.7.0",
|
||||||
"xml2js": "0.5.0",
|
"xml2js": "0.5.0",
|
||||||
"yargs": "13.2.4",
|
"yargs": "13.2.4",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/shared-core",
|
"name": "@budibase/shared-core",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Shared data utils",
|
"description": "Shared data utils",
|
||||||
"main": "dist/cjs/src/index.js",
|
"main": "dist/cjs/src/index.js",
|
||||||
"types": "dist/mjs/src/index.d.ts",
|
"types": "dist/mjs/src/index.d.ts",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
|
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/types": "2.4.44-alpha.26"
|
"@budibase/types": "^2.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "^7.6.0",
|
"concurrently": "^7.6.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/string-templates",
|
"name": "@budibase/string-templates",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Handlebars wrapper for Budibase templating.",
|
"description": "Handlebars wrapper for Budibase templating.",
|
||||||
"main": "src/index.cjs",
|
"main": "src/index.cjs",
|
||||||
"module": "dist/bundle.mjs",
|
"module": "dist/bundle.mjs",
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
"handlebars": "^4.7.6",
|
"handlebars": "^4.7.6",
|
||||||
"handlebars-utils": "^1.0.6",
|
"handlebars-utils": "^1.0.6",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"vm2": "^3.9.4"
|
"vm2": "^3.9.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-commonjs": "^17.1.0",
|
"@rollup/plugin-commonjs": "^17.1.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/types",
|
"name": "@budibase/types",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Budibase types",
|
"description": "Budibase types",
|
||||||
"main": "dist/cjs/index.js",
|
"main": "dist/cjs/index.js",
|
||||||
"types": "dist/mjs/index.d.ts",
|
"types": "dist/mjs/index.d.ts",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@budibase/worker",
|
"name": "@budibase/worker",
|
||||||
"email": "hi@budibase.com",
|
"email": "hi@budibase.com",
|
||||||
"version": "2.4.44-alpha.26",
|
"version": "2.5.4",
|
||||||
"description": "Budibase background service",
|
"description": "Budibase background service",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -37,10 +37,10 @@
|
||||||
"author": "Budibase",
|
"author": "Budibase",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@budibase/backend-core": "2.4.44-alpha.26",
|
"@budibase/backend-core": "^2.5.4",
|
||||||
"@budibase/pro": "2.4.44-alpha.26",
|
"@budibase/pro": "2.5.4",
|
||||||
"@budibase/string-templates": "2.4.44-alpha.26",
|
"@budibase/string-templates": "^2.5.4",
|
||||||
"@budibase/types": "2.4.44-alpha.26",
|
"@budibase/types": "^2.5.4",
|
||||||
"@koa/router": "8.0.8",
|
"@koa/router": "8.0.8",
|
||||||
"@sentry/node": "6.17.7",
|
"@sentry/node": "6.17.7",
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
|
|
|
@ -126,9 +126,8 @@ describe("/api/global/auth", () => {
|
||||||
it("should prevent user from logging in", async () => {
|
it("should prevent user from logging in", async () => {
|
||||||
user = await config.createUser()
|
user = await config.createUser()
|
||||||
const account = structures.accounts.ssoAccount() as CloudAccount
|
const account = structures.accounts.ssoAccount() as CloudAccount
|
||||||
mocks.accounts.getAccount.mockReturnValueOnce(
|
account.email = user.email
|
||||||
Promise.resolve(account)
|
mocks.accounts.getAccountByTenantId.mockResolvedValueOnce(account)
|
||||||
)
|
|
||||||
|
|
||||||
await testSSOUser()
|
await testSSOUser()
|
||||||
})
|
})
|
||||||
|
@ -186,9 +185,8 @@ describe("/api/global/auth", () => {
|
||||||
it("should prevent user from generating password reset email", async () => {
|
it("should prevent user from generating password reset email", async () => {
|
||||||
user = await config.createUser(structures.users.user())
|
user = await config.createUser(structures.users.user())
|
||||||
const account = structures.accounts.ssoAccount() as CloudAccount
|
const account = structures.accounts.ssoAccount() as CloudAccount
|
||||||
mocks.accounts.getAccount.mockReturnValueOnce(
|
account.email = user.email
|
||||||
Promise.resolve(account)
|
mocks.accounts.getAccountByTenantId.mockResolvedValueOnce(account)
|
||||||
)
|
|
||||||
|
|
||||||
await testSSOUser()
|
await testSSOUser()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { structures } from "../../../tests"
|
import { structures } from "../../../tests"
|
||||||
import { mocks } from "@budibase/backend-core/tests"
|
import { mocks } from "@budibase/backend-core/tests"
|
||||||
import { env } from "@budibase/backend-core"
|
import { env, context } from "@budibase/backend-core"
|
||||||
import * as users from "../users"
|
import * as users from "../users"
|
||||||
import { CloudAccount } from "@budibase/types"
|
import { CloudAccount } from "@budibase/types"
|
||||||
import { isPreventPasswordActions } from "../users"
|
import { isPreventPasswordActions } from "../users"
|
||||||
|
@ -16,32 +16,50 @@ describe("users", () => {
|
||||||
|
|
||||||
describe("isPreventPasswordActions", () => {
|
describe("isPreventPasswordActions", () => {
|
||||||
it("returns false for non sso user", async () => {
|
it("returns false for non sso user", async () => {
|
||||||
const user = structures.users.user()
|
await context.doInTenant(structures.tenant.id(), async () => {
|
||||||
const result = await users.isPreventPasswordActions(user)
|
const user = structures.users.user()
|
||||||
expect(result).toBe(false)
|
const result = await users.isPreventPasswordActions(user)
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns true for sso account user", async () => {
|
it("returns true for sso account user", async () => {
|
||||||
const user = structures.users.user()
|
await context.doInTenant(structures.tenant.id(), async () => {
|
||||||
mocks.accounts.getAccount.mockReturnValue(
|
const user = structures.users.user()
|
||||||
Promise.resolve(structures.accounts.ssoAccount() as CloudAccount)
|
const account = structures.accounts.ssoAccount() as CloudAccount
|
||||||
)
|
account.email = user.email
|
||||||
const result = await users.isPreventPasswordActions(user)
|
mocks.accounts.getAccountByTenantId.mockResolvedValueOnce(account)
|
||||||
expect(result).toBe(true)
|
const result = await users.isPreventPasswordActions(user)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("returns false when account doesn't match user email", async () => {
|
||||||
|
await context.doInTenant(structures.tenant.id(), async () => {
|
||||||
|
const user = structures.users.user()
|
||||||
|
const account = structures.accounts.ssoAccount() as CloudAccount
|
||||||
|
mocks.accounts.getAccountByTenantId.mockResolvedValueOnce(account)
|
||||||
|
const result = await users.isPreventPasswordActions(user)
|
||||||
|
expect(result).toBe(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns true for sso user", async () => {
|
it("returns true for sso user", async () => {
|
||||||
const user = structures.users.ssoUser()
|
await context.doInTenant(structures.tenant.id(), async () => {
|
||||||
const result = await users.isPreventPasswordActions(user)
|
const user = structures.users.ssoUser()
|
||||||
expect(result).toBe(true)
|
const result = await users.isPreventPasswordActions(user)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("enforced sso", () => {
|
describe("enforced sso", () => {
|
||||||
it("returns true for all users when sso is enforced", async () => {
|
it("returns true for all users when sso is enforced", async () => {
|
||||||
const user = structures.users.user()
|
await context.doInTenant(structures.tenant.id(), async () => {
|
||||||
pro.features.isSSOEnforced.mockReturnValue(Promise.resolve(true))
|
const user = structures.users.user()
|
||||||
const result = await users.isPreventPasswordActions(user)
|
pro.features.isSSOEnforced.mockResolvedValueOnce(true)
|
||||||
expect(result).toBe(true)
|
const result = await users.isPreventPasswordActions(user)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import {
|
||||||
SearchUsersRequest,
|
SearchUsersRequest,
|
||||||
User,
|
User,
|
||||||
SaveUserOpts,
|
SaveUserOpts,
|
||||||
|
Account,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { sendEmail } from "../../utilities/email"
|
import { sendEmail } from "../../utilities/email"
|
||||||
import { EmailTemplatePurpose } from "../../constants"
|
import { EmailTemplatePurpose } from "../../constants"
|
||||||
|
@ -90,7 +91,8 @@ const buildUser = async (
|
||||||
requirePassword: true,
|
requirePassword: true,
|
||||||
},
|
},
|
||||||
tenantId: string,
|
tenantId: string,
|
||||||
dbUser?: any
|
dbUser?: any,
|
||||||
|
account?: Account
|
||||||
): Promise<User> => {
|
): Promise<User> => {
|
||||||
let { password, _id } = user
|
let { password, _id } = user
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ const buildUser = async (
|
||||||
|
|
||||||
let hashedPassword
|
let hashedPassword
|
||||||
if (password) {
|
if (password) {
|
||||||
if (await isPreventPasswordActions(user)) {
|
if (await isPreventPasswordActions(user, account)) {
|
||||||
throw new HTTPError("Password change is disabled for this user", 400)
|
throw new HTTPError("Password change is disabled for this user", 400)
|
||||||
}
|
}
|
||||||
hashedPassword = opts.hashPassword ? await utils.hash(password) : password
|
hashedPassword = opts.hashPassword ? await utils.hash(password) : password
|
||||||
|
@ -172,7 +174,7 @@ const validateUniqueUser = async (email: string, tenantId: string) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isPreventPasswordActions(user: User) {
|
export async function isPreventPasswordActions(user: User, account?: Account) {
|
||||||
// when in maintenance mode we allow sso users with the admin role
|
// when in maintenance mode we allow sso users with the admin role
|
||||||
// to perform any password action - this prevents lockout
|
// to perform any password action - this prevents lockout
|
||||||
if (coreEnv.ENABLE_SSO_MAINTENANCE_MODE && user.admin?.global) {
|
if (coreEnv.ENABLE_SSO_MAINTENANCE_MODE && user.admin?.global) {
|
||||||
|
@ -190,8 +192,10 @@ export async function isPreventPasswordActions(user: User) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check account sso
|
// Check account sso
|
||||||
const account = await accountSdk.api.getAccount(user.email)
|
if (!account) {
|
||||||
return !!(account && isSSOAccount(account))
|
account = await accountSdk.api.getAccountByTenantId(tenancy.getTenantId())
|
||||||
|
}
|
||||||
|
return !!(account && account.email === user.email && isSSOAccount(account))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const save = async (
|
export const save = async (
|
||||||
|
@ -402,6 +406,7 @@ export const bulkCreate = async (
|
||||||
newUsers.push(newUser)
|
newUsers.push(newUser)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const account = await accountSdk.api.getAccountByTenantId(tenantId)
|
||||||
// create the promises array that will be called by bulkDocs
|
// create the promises array that will be called by bulkDocs
|
||||||
newUsers.forEach((user: any) => {
|
newUsers.forEach((user: any) => {
|
||||||
usersToSave.push(
|
usersToSave.push(
|
||||||
|
@ -411,7 +416,9 @@ export const bulkCreate = async (
|
||||||
hashPassword: true,
|
hashPassword: true,
|
||||||
requirePassword: user.requirePassword,
|
requirePassword: user.requirePassword,
|
||||||
},
|
},
|
||||||
tenantId
|
tenantId,
|
||||||
|
undefined, // no dbUser
|
||||||
|
account
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue