fix: fix username check

User names in the domain can not be repeated, check the name check when creating and editing user

Change-Id: I2cc2f6c800d85619cb9f3ca12e2e4b7d93c52125
This commit is contained in:
zhangjingwei 2023-11-09 09:55:17 +08:00
parent 2075632e36
commit 663f8a2665
5 changed files with 23 additions and 7 deletions

View File

@ -1334,7 +1334,7 @@
"Invalid: Project names in the domain can not be repeated": "Invalid: Project names in the domain can not be repeated",
"Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.": "Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.",
"Invalid: User Group name can not be duplicated": "Invalid: User Group name can not be duplicated",
"Invalid: User name can not be duplicated": "Invalid: User name can not be duplicated",
"Invalid: User names in the domain can not be repeated": "Invalid: User names in the domain can not be repeated",
"Ip Address": "Ip Address",
"Iran (Islamic Republic of)": "Iran (Islamic Republic of)",
"Iraq": "Iraq",

View File

@ -1334,7 +1334,7 @@
"Invalid: Project names in the domain can not be repeated": "유효하지 않음: 도메인의 프로젝트 이름은 반복될 수 없습니다.",
"Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.": "잘못됨: 할당량 값은 현재 사용 값보다 작을 수 없습니다: { used } 사용됨.",
"Invalid: User Group name can not be duplicated": "잘못됨: 사용자 그룹 이름은 중복될 수 없습니다.",
"Invalid: User name can not be duplicated": "잘못됨: 사용자 이름은 중복될 수 없습니다.",
"Invalid: User names in the domain can not be repeated": "유효하지 않음: 도메인의 사용자 이름은 반복될 수 없습니다.",
"Ip Address": "IP 주소",
"Iran (Islamic Republic of)": "",
"Iraq": "",

View File

@ -1334,7 +1334,7 @@
"Invalid: Project names in the domain can not be repeated": "无效:域下的项目名称不能重复",
"Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.": "无效:配额必须大于已使用数量{ used }且为整数",
"Invalid: User Group name can not be duplicated": "无效:用户组名称不可重复",
"Invalid: User name can not be duplicated": "无效:用户名称不可重复",
"Invalid: User names in the domain can not be repeated": "无效:域下的用户名称不能重复",
"Ip Address": "IP地址",
"Iran (Islamic Republic of)": "伊朗",
"Iraq": "伊拉克",

View File

@ -221,12 +221,20 @@ export class Create extends FormAction {
if (!value) {
return Promise.reject(t('Please input'));
}
const domainId = this.formRef.current.getFieldValue('domain_id');
if (!domainId) {
return Promise.resolve();
}
const {
list: { data },
} = this.store;
const nameUsed = data.filter((it) => it.name === value);
const nameUsed = data.filter(
(it) => it.name === value && it.domain_id === domainId
);
if (nameUsed[0]) {
return Promise.reject(t('Invalid: User name can not be duplicated'));
return Promise.reject(
t('Invalid: User names in the domain can not be repeated')
);
}
return Promise.resolve();
};
@ -261,6 +269,7 @@ export class Create extends FormAction {
required: true,
...cols,
maxLength: 30,
dependencies: ['domain_id'],
},
{
name: 'email',

View File

@ -67,9 +67,16 @@ export class EditForm extends ModalAction {
list: { data },
} = this.store;
const { id } = this.item;
const nameUsed = data.find((it) => it.name === value && it.id !== id);
const nameUsed = data.find(
(it) =>
it.name === value &&
it.id !== id &&
it.domain_id === this.item.domain_id
);
if (nameUsed) {
return Promise.reject(t('Invalid: User name can not be duplicated'));
return Promise.reject(
t('Invalid: User names in the domain can not be repeated')
);
}
return Promise.resolve();
};