Creating a new user with an existing user name

Change error message when we create a new user
with an existing user name.

Change-Id: I795c04672a3c625be074c8af78eb169436ac3895
Closes-Bug: #1404432
This commit is contained in:
Yash Bathia 2014-12-19 19:39:12 -08:00
parent 5315911e14
commit 0dc91bed5c
2 changed files with 13 additions and 6 deletions

View File

@ -300,12 +300,16 @@ def user_list(request, project=None, domain=None, group=None):
def user_create(request, name=None, email=None, password=None, project=None,
enabled=None, domain=None):
manager = keystoneclient(request, admin=True).users
if VERSIONS.active < 3:
user = manager.create(name, password, email, project, enabled)
return VERSIONS.upgrade_v2_user(user)
else:
return manager.create(name, password=password, email=email,
project=project, enabled=enabled, domain=domain)
try:
if VERSIONS.active < 3:
user = manager.create(name, password, email, project, enabled)
return VERSIONS.upgrade_v2_user(user)
else:
return manager.create(name, password=password, email=email,
project=project, enabled=enabled,
domain=domain)
except keystone_exceptions.Conflict:
raise exceptions.Conflict()
def user_delete(request, user_id):

View File

@ -145,6 +145,9 @@ class CreateUserForm(BaseUserForm):
_('Unable to add user '
'to primary project.'))
return new_user
except exceptions.Conflict:
msg = _('User name "%s" is already used.') % data['name']
messages.error(request, msg)
except Exception:
exceptions.handle(request, _('Unable to create user.'))