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
b670259a
Commit
b670259a
authored
Jan 02, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify terminal reqject templatte
parent
0907f502
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
7 deletions
+16
-7
models.py
apps/applications/models.py
+7
-1
terminal_list.html
apps/applications/templates/applications/terminal_list.html
+3
-1
utils.py
apps/audits/utils.py
+3
-2
api.py
apps/users/api.py
+1
-1
utils.py
apps/users/utils.py
+2
-2
No files found.
apps/applications/models.py
View file @
b670259a
...
...
@@ -14,7 +14,8 @@ class Terminal(models.Model):
name
=
models
.
CharField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
_
(
'Name'
))
remote_addr
=
models
.
GenericIPAddressField
(
verbose_name
=
_
(
'Remote address'
),
blank
=
True
,
null
=
True
)
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
3
,
blank
=
True
,
verbose_name
=
_
(
'Terminal type'
))
user
=
models
.
OneToOneField
(
User
,
related_name
=
'terminal'
,
verbose_name
=
'Application user'
,
null
=
True
)
user
=
models
.
OneToOneField
(
User
,
related_name
=
'terminal'
,
verbose_name
=
'Application user'
,
null
=
True
,
on_delete
=
models
.
CASCADE
)
url
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
,
verbose_name
=
_
(
'URL to login'
))
is_accepted
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'Is Accepted'
)
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
...
...
@@ -38,6 +39,11 @@ class Terminal(models.Model):
self
.
save
()
return
user
,
access_key
def
delete
(
self
,
using
=
None
,
keep_parents
=
False
):
if
self
.
user
:
self
.
user
.
delete
()
return
super
(
Terminal
,
self
)
.
delete
(
using
=
using
,
keep_parents
=
keep_parents
)
def
__unicode__
(
self
):
active
=
'Active'
if
self
.
user
and
self
.
user
.
is_active
else
'Disabled'
return
'
%
s:
%
s'
%
(
self
.
name
,
active
)
...
...
apps/applications/templates/applications/terminal_list.html
View file @
b670259a
...
...
@@ -76,7 +76,9 @@ $(document).ready(function(){
.
replace
(
'99991938'
,
rowData
.
name
);
var
accept_btn
=
'<a class="btn btn-xs btn-primary btn-accept" data-id="99991937">{% trans "Accept" %}</a> '
.
replace
(
'99991937'
,
cellData
);
var
reject_btn
=
'<a href="" class="btn btn-xs btn-danger">{% trans "Reject" %}</a>'
var
reject_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn_delete" data-uid="99991937" data-name="99991938">{% trans "Reject" %}</a>'
.
replace
(
'99991937'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
if
(
rowData
.
is_accepted
)
{
$
(
td
).
html
(
update_btn
+
delete_btn
)
}
else
{
...
...
apps/audits/utils.py
View file @
b670259a
...
...
@@ -35,14 +35,15 @@ def get_ip_city(ip, timeout=10):
url
=
'http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip=
%
s&format=json'
%
ip
try
:
r
=
requests
.
get
(
url
,
timeout
=
timeout
)
print
(
r
)
except
requests
.
Timeout
:
r
=
None
city
=
'Unknown'
if
r
and
r
.
status_code
==
200
:
try
:
data
=
r
.
json
()
if
data
[
'code'
]
==
0
:
city
=
data
[
'
data'
][
'country'
]
+
data
[
'data'
]
[
'city'
]
if
not
isinstance
(
data
,
int
)
and
data
[
'ret'
]
==
1
:
city
=
data
[
'
country'
]
+
' '
+
data
[
'city'
]
except
ValueError
:
pass
return
city
...
...
apps/users/api.py
View file @
b670259a
...
...
@@ -121,7 +121,7 @@ class UserAuthApi(APIView):
password
=
request
.
data
.
get
(
'password'
,
''
)
public_key
=
request
.
data
.
get
(
'public_key'
,
''
)
login_type
=
request
.
data
.
get
(
'login_type'
,
''
)
login_ip
=
request
.
META
.
get
(
'REMOTE_ADDR'
,
''
)
login_ip
=
request
.
data
.
get
(
'remote_addr'
,
None
)
or
request
.
META
.
get
(
'REMOTE_ADDR'
,
''
)
user_agent
=
request
.
data
.
get
(
'HTTP_USER_AGENT'
,
''
)
user
,
msg
=
check_user_valid
(
username
=
username
,
password
=
password
,
public_key
=
public_key
)
...
...
apps/users/utils.py
View file @
b670259a
...
...
@@ -195,10 +195,10 @@ def check_user_valid(**kwargs):
elif
not
user
.
is_valid
:
return
None
,
_
(
'Disabled or expired'
)
if
password
and
user
.
check_password
(
password
):
if
password
and
user
.
password
and
user
.
check_password
(
password
):
return
user
,
''
if
public_key
:
if
public_key
and
user
.
public_key
:
public_key_saved
=
user
.
public_key
.
split
()
if
len
(
public_key_saved
)
==
1
:
if
public_key
==
public_key_saved
[
0
]:
...
...
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