Commit e5286686 authored by 老广's avatar 老广 Committed by GitHub

Update views.py

check valid user when username == 'root'
parent 8f666785
......@@ -159,11 +159,16 @@ def user_add(request):
if '' in [username, password, ssh_key_pwd, name, role]:
error = u'带*内容不能为空'
raise ServerError
check_user_is_exist = User.objects.filter(username=username)
if check_user_is_exist:
error = u'用户 %s 已存在' % username
raise ServerError
if username in ['root']:
error = u'用户不能为root'
raise ServerError
except ServerError:
pass
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment