Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
08a8afa6
Commit
08a8afa6
authored
10 years ago
by
David Baumgold
Browse files
Options
Downloads
Patches
Plain Diff
For methods on PasswordHistory, only calculate if necessary
Check settings.FEATURES["ADVANCED_SECURITY"] first
parent
4fcf1f9e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/djangoapps/student/models.py
+15
-5
15 additions, 5 deletions
common/djangoapps/student/models.py
with
15 additions
and
5 deletions
common/djangoapps/student/models.py
+
15
−
5
View file @
08a8afa6
...
...
@@ -452,50 +452,60 @@ class PasswordHistory(models.Model):
"""
Returns whether the configuration which limits password reuse has been turned on
"""
if
not
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]:
return
False
min_diff_pw
=
settings
.
ADVANCED_SECURITY_CONFIG
.
get
(
'
MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE
'
,
0
)
return
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]
and
min_diff_pw
>
0
return
min_diff_pw
>
0
@classmethod
def
is_staff_password_reuse_restricted
(
cls
):
"""
Returns whether the configuration which limits password reuse has been turned on
"""
if
not
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]:
return
False
min_diff_pw
=
settings
.
ADVANCED_SECURITY_CONFIG
.
get
(
'
MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE
'
,
0
)
return
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]
and
min_diff_pw
>
0
return
min_diff_pw
>
0
@classmethod
def
is_password_reset_frequency_restricted
(
cls
):
"""
Returns whether the configuration which limits the password reset frequency has been turned on
"""
if
not
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]:
return
False
min_days_between_reset
=
settings
.
ADVANCED_SECURITY_CONFIG
.
get
(
'
MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS
'
)
return
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]
and
min_days_between_reset
return
min_days_between_reset
@classmethod
def
is_staff_forced_password_reset_enabled
(
cls
):
"""
Returns whether the configuration which forces password resets to occur has been turned on
"""
if
not
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]:
return
False
min_days_between_reset
=
settings
.
ADVANCED_SECURITY_CONFIG
.
get
(
'
MIN_DAYS_FOR_STAFF_ACCOUNTS_PASSWORD_RESETS
'
)
return
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]
and
min_days_between_reset
return
min_days_between_reset
@classmethod
def
is_student_forced_password_reset_enabled
(
cls
):
"""
Returns whether the configuration which forces password resets to occur has been turned on
"""
if
not
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]:
return
False
min_days_pw_reset
=
settings
.
ADVANCED_SECURITY_CONFIG
.
get
(
'
MIN_DAYS_FOR_STUDENT_ACCOUNTS_PASSWORD_RESETS
'
)
return
settings
.
FEATURES
[
'
ADVANCED_SECURITY
'
]
and
min_days_pw_reset
return
min_days_pw_reset
@classmethod
def
should_user_reset_password_now
(
cls
,
user
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment