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
bea5dadb
Commit
bea5dadb
authored
Nov 15, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改终端注册条件判断逻辑(从 serializer -> view)
parent
f3d2e5d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
terminal.py
apps/terminal/api_v2/terminal.py
+4
-0
terminal.py
apps/terminal/serializers_v2/terminal.py
+0
-3
No files found.
apps/terminal/api_v2/terminal.py
View file @
bea5dadb
...
...
@@ -3,6 +3,7 @@
from
rest_framework
import
viewsets
,
generics
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
django.conf
import
settings
from
common.permissions
import
IsSuperUser
,
WithBootstrapToken
...
...
@@ -29,6 +30,9 @@ class TerminalRegistrationApi(generics.CreateAPIView):
serializer
=
serializers
.
TerminalSerializer
(
data
=
data
,
context
=
{
'request'
:
request
}
)
if
not
settings
.
SECURITY_SERVICE_ACCOUNT_REGISTRATION
:
data
=
{
"error"
:
"service account registration disabled"
}
return
Response
(
data
=
data
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
serializer
.
is_valid
(
raise_exception
=
True
)
terminal
=
serializer
.
save
()
sa_serializer
=
serializer
.
sa_serializer_class
(
instance
=
terminal
.
user
)
...
...
apps/terminal/serializers_v2/terminal.py
View file @
bea5dadb
...
...
@@ -28,9 +28,6 @@ class TerminalSerializer(serializers.ModelSerializer):
valid
=
super
()
.
is_valid
(
raise_exception
=
raise_exception
)
if
not
valid
:
return
valid
if
not
settings
.
SECURITY_SERVICE_ACCOUNT_REGISTRATION
:
error
=
{
"error"
:
"service account registration disabled"
}
raise
serializers
.
ValidationError
(
error
)
data
=
{
'name'
:
self
.
validated_data
.
get
(
'name'
)}
kwargs
=
{
'data'
:
data
}
if
self
.
instance
and
self
.
instance
.
user
:
...
...
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