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:
parent
5315911e14
commit
0dc91bed5c
@ -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,
|
def user_create(request, name=None, email=None, password=None, project=None,
|
||||||
enabled=None, domain=None):
|
enabled=None, domain=None):
|
||||||
manager = keystoneclient(request, admin=True).users
|
manager = keystoneclient(request, admin=True).users
|
||||||
if VERSIONS.active < 3:
|
try:
|
||||||
user = manager.create(name, password, email, project, enabled)
|
if VERSIONS.active < 3:
|
||||||
return VERSIONS.upgrade_v2_user(user)
|
user = manager.create(name, password, email, project, enabled)
|
||||||
else:
|
return VERSIONS.upgrade_v2_user(user)
|
||||||
return manager.create(name, password=password, email=email,
|
else:
|
||||||
project=project, enabled=enabled, domain=domain)
|
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):
|
def user_delete(request, user_id):
|
||||||
|
@ -145,6 +145,9 @@ class CreateUserForm(BaseUserForm):
|
|||||||
_('Unable to add user '
|
_('Unable to add user '
|
||||||
'to primary project.'))
|
'to primary project.'))
|
||||||
return new_user
|
return new_user
|
||||||
|
except exceptions.Conflict:
|
||||||
|
msg = _('User name "%s" is already used.') % data['name']
|
||||||
|
messages.error(request, msg)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, _('Unable to create user.'))
|
exceptions.handle(request, _('Unable to create user.'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user