diff --git a/src/pages/identity/containers/User/actionsInDomain/Create.jsx b/src/pages/identity/containers/User/actionsInDomain/Create.jsx index ecd7745f..d76ea85f 100644 --- a/src/pages/identity/containers/User/actionsInDomain/Create.jsx +++ b/src/pages/identity/containers/User/actionsInDomain/Create.jsx @@ -29,6 +29,7 @@ export class CreateForm extends ModalAction { this.projectStore = globalProjectStore; this.roleStore = globalRoleStore; this.domainStore = globalDomainStore; + this.getAllUser(); this.getUserGroup(); this.getProject(); this.getRole(); @@ -39,6 +40,10 @@ export class CreateForm extends ModalAction { return t('Create User'); } + async getAllUser() { + this.allUser = await this.store.pureFetchList(); + } + getUserGroup() { this.userGroupStore.fetchList(); } @@ -63,6 +68,17 @@ export class CreateForm extends ModalAction { 'identity:list_domains', ]; + checkName = (rule, value) => { + if (!value) { + return Promise.reject(t('Please input')); + } + const nameUsed = this.allUser.find((i) => i.name === value); + if (nameUsed) { + return Promise.reject(t('Invalid: User name can not be duplicated')); + } + return Promise.resolve(); + }; + static allowed(item, containerProps) { const { match: { path }, @@ -138,6 +154,7 @@ export class CreateForm extends ModalAction { name: 'name', label: t('User Name'), type: 'input', + validator: this.checkName, placeholder: t('Please input user name'), required: true, }, @@ -226,8 +243,6 @@ export class CreateForm extends ModalAction { real_name, default_project_id, }; - // eslint-disable-next-line no-console - console.log(data); return this.store.create(data); }; }