Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
26ad623d
Commit
26ad623d
authored
Jul 26, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix role delete
parent
f8eedc86
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
31 deletions
+34
-31
ansible_api.py
jperm/ansible_api.py
+6
-0
views.py
jperm/views.py
+0
-1
perm_role_list.html
templates/jperm/perm_role_list.html
+28
-30
No files found.
jperm/ansible_api.py
View file @
26ad623d
...
...
@@ -316,6 +316,8 @@ class MyTask(MyRunner):
"""
push the ssh authorized key to target.
"""
if
user
==
'root'
:
return
{
"status"
:
"failed"
,
"msg"
:
"root cann't be delete"
}
module_args
=
'user="
%
s" key="{{ lookup("file", "
%
s") }}" state="absent"'
%
(
user
,
key_path
)
self
.
run
(
"authorized_key"
,
module_args
,
become
=
True
)
...
...
@@ -361,6 +363,8 @@ class MyTask(MyRunner):
"""
delete a host user.
"""
if
username
==
'root'
:
return
{
"status"
:
"failed"
,
"msg"
:
"root cann't be delete"
}
module_args
=
'name=
%
s state=absent remove=yes move_home=yes force=yes'
%
username
self
.
run
(
"user"
,
module_args
,
become
=
True
)
return
self
.
results
...
...
@@ -371,6 +375,8 @@ class MyTask(MyRunner):
:param username:
:return:
"""
if
username
==
'root'
:
return
{
"status"
:
"failed"
,
"msg"
:
"root cann't be delete"
}
module_args
=
"sed -i 's/^
%
s.*//' /etc/sudoers"
%
username
self
.
run
(
"command"
,
module_args
,
become
=
True
)
return
self
.
results
...
...
jperm/views.py
View file @
26ad623d
...
...
@@ -333,7 +333,6 @@ def perm_role_delete(request):
raise
ServerError
(
u"role_id
%
s 无数据记录"
%
role_id
)
# 删除推送到主机上的role
filter_type
=
request
.
GET
.
get
(
"filter_type"
)
print
filter_type
if
filter_type
:
if
filter_type
==
"recycle_assets"
:
recycle_assets
=
[
push
.
asset
for
push
in
role
.
perm_push
.
all
()
if
push
.
success
]
...
...
templates/jperm/perm_role_list.html
View file @
26ad623d
...
...
@@ -87,39 +87,37 @@ function remove_role(role_id){
url
:
"{% url 'role_del' %}"
,
data
:
{
id
:
role_id
,
filter_type
:
'recycle_assets'
},
success
:
function
(
data
)
{
console
.
log
(
data
)
if
(
data
)
{
msg
=
data
+
"的系统用户会被删除,包括其家目录,请谨慎操作!"
}
else
{
msg
=
"该角色无已推送的系统用户, 可以安全删除"
}
if
(
confirm
(
msg
))
{
$
.
ajax
({
type
:
"POST"
,
url
:
"{% url 'role_del' %}"
,
data
:
"id="
+
role_id
,
success
:
function
(
msg
){
alert
(
"成功: "
+
msg
);
var
del_row
=
$
(
'tbody#edittbody>tr#'
+
role_id
);
del_row
.
remove
()
},
error
:
function
(
msg
)
{
console
.
log
(
msg
);
alert
(
"失败: "
+
msg
.
responseText
)
}
});
}
},
var
msg
=
data
+
" 资产上的系统用户会被删除, 包括其家目录,请谨慎操作!"
;
layer
.
alert
(
msg
,
{
title
:
'警告'
,
closeBtn
:
0
},
function
(){
layer
.
confirm
(
'危险动作, 除非你非常明白自己在做什么,否则请取消'
,
{
title
:
'再次确认'
,
btn
:
[
'确认'
,
'取消'
]
},
function
(){
$
.
ajax
({
type
:
"POST"
,
url
:
"{% url 'role_del' %}"
,
data
:
"id="
+
role_id
,
success
:
function
(
msg
){
layer
.
msg
(
"成功: "
+
msg
);
var
del_row
=
$
(
'tbody#edittbody>tr#'
+
role_id
);
del_row
.
remove
()
},
error
:
function
(
msg
)
{
console
.
log
(
msg
);
layer
.
alert
(
"失败: "
+
msg
.
responseText
)
}
});
},
function
(){
layer
.
msg
(
'取消'
,
{
icon
:
1
})
})
})},
error
:
function
(
error
)
{
alert
(
error
)
}
,
}
});
}
</script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment