feat(tenant): implement tenant creation limit and error handling

Added a new configuration option to limit the number of tenants a non-superuser can create via self-service. Introduced a new error type for handling cases where users exceed this limit, returning a 429 status code. Updated the tenant creation and update handlers to enforce this limit and provide appropriate feedback to users. Additionally, refactored the tenant update request structure to ensure only mutable fields are allowed.

Refs: #1303
This commit is contained in:
wizardchen
2026-05-16 10:37:25 +08:00
committed by lyingbug
parent 29dc99ae79
commit 7d030a6f6a
7 changed files with 497 additions and 698 deletions
@@ -62,10 +62,17 @@ const form = reactive({
description: '',
})
// Trim-aware required check:t-input 的 required 不会去空白,全空格也算
// 通过;这里手动校验 trim 后非空,避免后端因 binding:"required,min=1"
// 才把请求挡下来。max 长度由 <t-input :maxlength="128"> 在键入时硬限制,
// 所以这里不再重复挂规则(避免与硬限制双重提示)。
const formRules: Record<string, FormRule[]> = {
name: [
{ required: true, message: t('tenant.create.nameRequired'), trigger: 'blur' },
{ max: 128, message: t('tenant.create.nameRequired'), trigger: 'blur' },
{
validator: (val: string) => (val ?? '').trim().length > 0,
message: t('tenant.create.nameRequired'),
trigger: 'blur',
},
],
}