1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 00:00:00 +00:00

[user-admin] add try-exception when fail to add a user

This commit is contained in:
lian
2015-05-07 11:38:29 +08:00
parent 756177c952
commit 9bfebfb2b6

View File

@@ -894,8 +894,14 @@ def user_add(request):
role = form.cleaned_data['role']
password = form.cleaned_data['password1']
user = User.objects.create_user(email, password, is_staff=False,
is_active=True)
try:
user = User.objects.create_user(email, password, is_staff=False,
is_active=True)
except User.DoesNotExist as e:
logger.error(e)
err_msg = _(u'Fail to add user %s.') % email
return HttpResponse(json.dumps({'error': err_msg}), status=403, content_type=content_type)
if user:
User.objects.update_role(email, role)