For methods on PasswordHistory, only calculate if necessary
Check settings.FEATURES["ADVANCED_SECURITY"] first
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user