Validate password on admin creation

This commit is contained in:
Adria Navarro 2024-01-02 13:23:08 +01:00
parent 3b50d1a988
commit e50cc35140
2 changed files with 7 additions and 1 deletions

View File

@ -38,7 +38,7 @@
$goto("../portal")
} catch (error) {
submitted = false
notifications.error("Failed to create admin user")
notifications.error(error.message || "Failed to create admin user")
}
}
</script>

View File

@ -27,6 +27,7 @@ import {
platform,
tenancy,
db,
security,
} from "@budibase/backend-core"
import { checkAnyUserExists } from "../../../utilities/users"
import { isEmailConfigured } from "../../../utilities/email"
@ -98,6 +99,11 @@ export const adminUser = async (
ctx.throw(403, "Organisation already exists.")
}
const passwordValidation = security.validatePassword(password)
if (!passwordValidation.valid) {
ctx.throw(400, passwordValidation.error)
}
if (env.MULTI_TENANCY) {
// store the new tenant record in the platform db
await platform.tenants.addTenant(tenantId)