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
33dc7dec
Unverified
Commit
33dc7dec
authored
Dec 20, 2019
by
BaiJiangJie
Committed by
GitHub
Dec 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3554 from jumpserver/master_auth
[Update] 修改校验用户有效性逻辑
parents
a88db3d9
b90960e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
21 deletions
+5
-21
utils.py
apps/authentication/utils.py
+5
-21
No files found.
apps/authentication/utils.py
View file @
33dc7dec
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
#
from
django.utils.translation
import
ugettext
as
_
from
django.contrib.auth
import
authenticate
from
django.contrib.auth
import
authenticate
from
common.utils
import
(
get_ip_city
,
get_object_or_none
,
validate_ip
)
from
users.models
import
User
from
.
import
errors
from
.
import
errors
def
check_user_valid
(
**
kwargs
):
def
check_user_valid
(
**
kwargs
):
password
=
kwargs
.
pop
(
'password'
,
None
)
password
=
kwargs
.
pop
(
'password'
,
None
)
public_key
=
kwargs
.
pop
(
'public_key'
,
None
)
public_key
=
kwargs
.
pop
(
'public_key'
,
None
)
email
=
kwargs
.
pop
(
'email'
,
None
)
username
=
kwargs
.
pop
(
'username'
,
None
)
username
=
kwargs
.
pop
(
'username'
,
None
)
request
=
kwargs
.
get
(
'request'
)
request
=
kwargs
.
get
(
'request'
)
if
username
:
user
=
authenticate
(
request
,
username
=
username
,
user
=
get_object_or_none
(
User
,
username
=
username
)
password
=
password
,
public_key
=
public_key
)
elif
email
:
if
not
user
:
user
=
get_object_or_none
(
User
,
email
=
email
)
return
None
,
errors
.
reason_password_failed
else
:
user
=
None
if
user
is
None
:
return
None
,
errors
.
reason_user_not_exist
elif
user
.
is_expired
:
elif
user
.
is_expired
:
return
None
,
errors
.
reason_user_inactive
return
None
,
errors
.
reason_user_inactive
elif
not
user
.
is_active
:
elif
not
user
.
is_active
:
...
@@ -33,9 +22,4 @@ def check_user_valid(**kwargs):
...
@@ -33,9 +22,4 @@ def check_user_valid(**kwargs):
elif
user
.
password_has_expired
:
elif
user
.
password_has_expired
:
return
None
,
errors
.
reason_password_expired
return
None
,
errors
.
reason_password_expired
if
password
or
public_key
:
return
user
,
''
user
=
authenticate
(
request
,
username
=
username
,
password
=
password
,
public_key
=
public_key
)
if
user
:
return
user
,
''
return
None
,
errors
.
reason_password_failed
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