diff --git a/webapp/packages/plugin-authentication/src/Administration/Users/UserForm/UserFormController.ts b/webapp/packages/plugin-authentication/src/Administration/Users/UserForm/UserFormController.ts index 6df0b0ee1f..c9ccfc9983 100644 --- a/webapp/packages/plugin-authentication/src/Administration/Users/UserForm/UserFormController.ts +++ b/webapp/packages/plugin-authentication/src/Administration/Users/UserForm/UserFormController.ts @@ -143,11 +143,21 @@ export class UserFormController implements IInitializableController, IDestructib }; private validate() { - if (!this.credentials.login) { + if (!this.credentials.login.trim()) { this.notificationService.logError({ title: 'authentication_user_login_not_set' }); return; } + if (this.rolesManagerService.roles.has(this.credentials.login)) { + this.notificationService.logError({ title: 'authentication_user_login_cant_be_used' }); + return; + } + + if (this.usersResource.has(this.credentials.login)) { + this.notificationService.logError({ title: 'authentication_user_login_already_exists' }); + return; + } + if (!this.isRoleSelected()) { this.notificationService.logError({ title: 'authentication_user_role_not_set' }); return; diff --git a/webapp/packages/plugin-authentication/src/locales/en.ts b/webapp/packages/plugin-authentication/src/locales/en.ts index 54fda62997..54598fa879 100644 --- a/webapp/packages/plugin-authentication/src/locales/en.ts +++ b/webapp/packages/plugin-authentication/src/locales/en.ts @@ -25,4 +25,6 @@ export default [ ['authentication_user_role_not_set', 'At least one role must be selected'], ['authentication_user_password_not_set', 'Password is required'], ['authentication_user_passwords_not_match', "Passwords don't match"], + ['authentication_user_login_already_exists', 'A user with this name already exists'], + ['authentication_user_login_cant_be_used', 'Sorry, that name cannot be used'], ]; diff --git a/webapp/packages/plugin-authentication/src/locales/ru.ts b/webapp/packages/plugin-authentication/src/locales/ru.ts index f64a4c792a..5a59ecddc9 100644 --- a/webapp/packages/plugin-authentication/src/locales/ru.ts +++ b/webapp/packages/plugin-authentication/src/locales/ru.ts @@ -25,4 +25,6 @@ export default [ ['authentication_user_role_not_set', 'Должна быть выбрана минимум одна роль'], ['authentication_user_password_not_set', 'Пароль не задан'], ['authentication_user_passwords_not_match', 'Пароли не совпадают'], + ['authentication_user_login_already_exists', 'Пользователь с таким именем уже существует'], + ['authentication_user_login_cant_be_used', 'Данное имя нельзя использовать'], ];