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

View File

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