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
681ddb5a
Commit
681ddb5a
authored
Jan 16, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] for login ip
parent
29061aa0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
2 deletions
+3
-2
api.py
apps/users/api.py
+1
-1
utils.py
apps/users/utils.py
+1
-0
login.py
apps/users/views/login.py
+1
-1
No files found.
apps/users/api.py
View file @
681ddb5a
...
@@ -128,7 +128,7 @@ class UserAuthApi(APIView):
...
@@ -128,7 +128,7 @@ class UserAuthApi(APIView):
user_agent
=
request
.
data
.
get
(
'HTTP_USER_AGENT'
,
''
)
user_agent
=
request
.
data
.
get
(
'HTTP_USER_AGENT'
,
''
)
if
not
login_ip
:
if
not
login_ip
:
x_forwarded_for
=
request
.
META
.
get
(
'HTTP_X_FORWARDED_FOR'
)
.
split
(
)
x_forwarded_for
=
request
.
META
.
get
(
'HTTP_X_FORWARDED_FOR'
,
''
)
.
split
(
','
)
if
x_forwarded_for
:
if
x_forwarded_for
:
login_ip
=
x_forwarded_for
[
0
]
login_ip
=
x_forwarded_for
[
0
]
else
:
else
:
...
...
apps/users/utils.py
View file @
681ddb5a
...
@@ -180,6 +180,7 @@ def validate_ip(ip):
...
@@ -180,6 +180,7 @@ def validate_ip(ip):
def
write_login_log
(
username
,
type
=
''
,
ip
=
''
,
user_agent
=
''
):
def
write_login_log
(
username
,
type
=
''
,
ip
=
''
,
user_agent
=
''
):
if
not
(
ip
and
validate_ip
(
ip
)):
if
not
(
ip
and
validate_ip
(
ip
)):
ip
=
ip
[:
15
]
city
=
"Unknown"
city
=
"Unknown"
else
:
else
:
city
=
get_ip_city
(
ip
)
city
=
get_ip_city
(
ip
)
...
...
apps/users/views/login.py
View file @
681ddb5a
...
@@ -53,7 +53,7 @@ class UserLoginView(FormView):
...
@@ -53,7 +53,7 @@ class UserLoginView(FormView):
if
not
self
.
request
.
session
.
test_cookie_worked
():
if
not
self
.
request
.
session
.
test_cookie_worked
():
return
HttpResponse
(
_
(
"Please enable cookies and try again."
))
return
HttpResponse
(
_
(
"Please enable cookies and try again."
))
auth_login
(
self
.
request
,
form
.
get_user
())
auth_login
(
self
.
request
,
form
.
get_user
())
x_forwarded_for
=
self
.
request
.
META
.
get
(
'HTTP_X_FORWARDED_FOR'
,
''
)
.
split
()
x_forwarded_for
=
self
.
request
.
META
.
get
(
'HTTP_X_FORWARDED_FOR'
,
''
)
.
split
(
','
)
if
x_forwarded_for
:
if
x_forwarded_for
:
login_ip
=
x_forwarded_for
[
0
]
login_ip
=
x_forwarded_for
[
0
]
else
:
else
:
...
...
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