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
b8ecb6f8
Commit
b8ecb6f8
authored
Aug 06, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 用户修改
parent
90c629c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
asset.py
apps/assets/views/asset.py
+2
-2
api.py
apps/users/api.py
+9
-1
hands.py
apps/users/hands.py
+1
-0
No files found.
apps/assets/views/asset.py
View file @
b8ecb6f8
...
@@ -186,7 +186,7 @@ class AssetDeleteView(AdminUserRequiredMixin, DeleteView):
...
@@ -186,7 +186,7 @@ class AssetDeleteView(AdminUserRequiredMixin, DeleteView):
success_url
=
reverse_lazy
(
'assets:asset-list'
)
success_url
=
reverse_lazy
(
'assets:asset-list'
)
class
AssetDetailView
(
DetailView
):
class
AssetDetailView
(
LoginRequiredMixin
,
DetailView
):
model
=
Asset
model
=
Asset
context_object_name
=
'asset'
context_object_name
=
'asset'
template_name
=
'assets/asset_detail.html'
template_name
=
'assets/asset_detail.html'
...
@@ -203,7 +203,7 @@ class AssetDetailView(DetailView):
...
@@ -203,7 +203,7 @@ class AssetDetailView(DetailView):
@method_decorator
(
csrf_exempt
,
name
=
'dispatch'
)
@method_decorator
(
csrf_exempt
,
name
=
'dispatch'
)
class
AssetExportView
(
View
):
class
AssetExportView
(
LoginRequiredMixin
,
View
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
spm
=
request
.
GET
.
get
(
'spm'
,
''
)
spm
=
request
.
GET
.
get
(
'spm'
,
''
)
assets_id_default
=
[
Asset
.
objects
.
first
()
.
id
]
if
Asset
.
objects
.
first
()
else
[]
assets_id_default
=
[
Asset
.
objects
.
first
()
.
id
]
if
Asset
.
objects
.
first
()
else
[]
...
...
apps/users/api.py
View file @
b8ecb6f8
...
@@ -3,6 +3,7 @@ import uuid
...
@@ -3,6 +3,7 @@ import uuid
from
django.core.cache
import
cache
from
django.core.cache
import
cache
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.shortcuts
import
get_object_or_404
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
rest_framework
import
generics
from
rest_framework
import
generics
...
@@ -20,6 +21,7 @@ from .utils import check_user_valid, generate_token, get_login_ip, \
...
@@ -20,6 +21,7 @@ from .utils import check_user_valid, generate_token, get_login_ip, \
check_otp_code
,
set_user_login_failed_count_to_cache
,
is_block_login
check_otp_code
,
set_user_login_failed_count_to_cache
,
is_block_login
from
orgs.utils
import
current_org
from
orgs.utils
import
current_org
from
common.permissions
import
IsOrgAdmin
,
IsCurrentUserOrReadOnly
,
IsOrgAdminOrAppUser
from
common.permissions
import
IsOrgAdmin
,
IsCurrentUserOrReadOnly
,
IsOrgAdminOrAppUser
from
.hands
import
Asset
,
SystemUser
from
common.mixins
import
IDInFilterMixin
from
common.mixins
import
IDInFilterMixin
from
common.utils
import
get_logger
from
common.utils
import
get_logger
...
@@ -311,10 +313,16 @@ class UserConnectionTokenApi(APIView):
...
@@ -311,10 +313,16 @@ class UserConnectionTokenApi(APIView):
asset_id
=
request
.
data
.
get
(
'asset'
,
''
)
asset_id
=
request
.
data
.
get
(
'asset'
,
''
)
system_user_id
=
request
.
data
.
get
(
'system_user'
,
''
)
system_user_id
=
request
.
data
.
get
(
'system_user'
,
''
)
token
=
str
(
uuid
.
uuid4
())
token
=
str
(
uuid
.
uuid4
())
user
=
get_object_or_404
(
User
,
id
=
user_id
)
asset
=
get_object_or_404
(
Asset
,
id
=
asset_id
)
system_user
=
get_object_or_404
(
SystemUser
,
id
=
system_user_id
)
value
=
{
value
=
{
'user'
:
user_id
,
'user'
:
user_id
,
'username'
:
user
.
username
,
'asset'
:
asset_id
,
'asset'
:
asset_id
,
'system_user'
:
system_user_id
'hostname'
:
asset
.
hostname
,
'system_user'
:
system_user_id
,
'system_user_name'
:
system_user
.
name
}
}
cache
.
set
(
token
,
value
,
timeout
=
20
)
cache
.
set
(
token
,
value
,
timeout
=
20
)
return
Response
({
"token"
:
token
},
status
=
201
)
return
Response
({
"token"
:
token
},
status
=
201
)
...
...
apps/users/hands.py
View file @
b8ecb6f8
...
@@ -15,3 +15,4 @@
...
@@ -15,3 +15,4 @@
# from users.models import User
# from users.models import User
# from perms.models import AssetPermission
# from perms.models import AssetPermission
# from perms.utils import get_user_granted_assets, get_user_granted_asset_groups
# from perms.utils import get_user_granted_assets, get_user_granted_asset_groups
from
assets.models
import
Asset
,
SystemUser
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