mirror of https://github.com/jumpserver/jumpserver
添加用户逻辑修改
parent
2acc715ebe
commit
c782b46f32
|
@ -121,6 +121,15 @@ def group_db_add(**kwargs):
|
|||
UserGroup.objects.create(**kwargs)
|
||||
|
||||
|
||||
def user_group_add(username, group_name):
|
||||
user = User.objects.get(username=username)
|
||||
group = UserGroup.objects.get(name=group_name)
|
||||
groups = [group]
|
||||
for g in user.user_group.all():
|
||||
groups.append(g)
|
||||
user.user_group = groups
|
||||
|
||||
|
||||
def group_add(request):
|
||||
error = ''
|
||||
msg = ''
|
||||
|
@ -461,6 +470,7 @@ def user_add(request):
|
|||
|
||||
server_add_user(username, password, ssh_key_pwd1)
|
||||
group_db_add(name=username, comment=username, type='U')
|
||||
user_group_add(username=username, group_name=username)
|
||||
if LDAP_ENABLE:
|
||||
ldap_add_user(username, ldap_pwd)
|
||||
msg = u'娣诲姞鐢ㄦ埛 %s 鎴愬姛锛' % username
|
||||
|
|
|
@ -168,13 +168,13 @@ $('#userForm').validator({
|
|||
msg: {required: "蹇呴』濉啓!"}
|
||||
},
|
||||
"password": {
|
||||
rule: "required;length[6~16]",
|
||||
rule: "required;length[6~50]",
|
||||
tip: "杈撳叆瀵嗙爜",
|
||||
ok: "",
|
||||
msg: {required: "蹇呴』濉啓!"}
|
||||
},
|
||||
"ssh_key_pwd1": {
|
||||
rule: "required;length[6~16]",
|
||||
rule: "required;length[6~50]",
|
||||
tip: "ssh绉侀挜瀵嗙爜",
|
||||
ok: "",
|
||||
msg: {required: "蹇呴』濉啓"}
|
||||
|
|
Loading鈥
Reference in New Issue