当前位置: 首页>>代码示例>>Python>>正文


Python PasswordHistory.is_password_reset_too_soon方法代码示例

本文整理汇总了Python中student.models.PasswordHistory.is_password_reset_too_soon方法的典型用法代码示例。如果您正苦于以下问题:Python PasswordHistory.is_password_reset_too_soon方法的具体用法?Python PasswordHistory.is_password_reset_too_soon怎么用?Python PasswordHistory.is_password_reset_too_soon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在student.models.PasswordHistory的用法示例。


在下文中一共展示了PasswordHistory.is_password_reset_too_soon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_too_frequent_password_resets

# 需要导入模块: from student.models import PasswordHistory [as 别名]
# 或者: from student.models.PasswordHistory import is_password_reset_too_soon [as 别名]
    def test_too_frequent_password_resets(self):
        """
        Assert that a user should not be able to password reset too frequently
        """
        student = self._user_factory_with_history()
        grandfathered_student = self._user_factory_with_history(set_initial_history=False)

        self.assertTrue(PasswordHistory.is_password_reset_too_soon(student))
        self.assertFalse(PasswordHistory.is_password_reset_too_soon(grandfathered_student))

        staff_reset_time = timezone.now() + timedelta(days=100)
        with freeze_time(staff_reset_time):
            self.assertFalse(PasswordHistory.is_password_reset_too_soon(student))
开发者ID:10clouds,项目名称:edx-platform,代码行数:15,代码来源:test_password_history.py

示例2: validate_password_security

# 需要导入模块: from student.models import PasswordHistory [as 别名]
# 或者: from student.models.PasswordHistory import is_password_reset_too_soon [as 别名]
def validate_password_security(password, user):
    """
    Check password reuse and similar operational security policy considerations.
    """
    # Check reuse
    if not PasswordHistory.is_allowable_password_reuse(user, password):
        if user.is_staff:
            num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE']
        else:
            num_distinct = settings.ADVANCED_SECURITY_CONFIG['MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE']
        raise SecurityPolicyError(ungettext(
            "You are re-using a password that you have used recently. "
            "You must have {num} distinct password before reusing a previous password.",
            "You are re-using a password that you have used recently. "
            "You must have {num} distinct passwords before reusing a previous password.",
            num_distinct
        ).format(num=num_distinct))

    # Check reset frequency
    if PasswordHistory.is_password_reset_too_soon(user):
        num_days = settings.ADVANCED_SECURITY_CONFIG['MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS']
        raise SecurityPolicyError(ungettext(
            "You are resetting passwords too frequently. Due to security policies, "
            "{num} day must elapse between password resets.",
            "You are resetting passwords too frequently. Due to security policies, "
            "{num} days must elapse between password resets.",
            num_days
        ).format(num=num_days))
开发者ID:EDUlib,项目名称:edx-platform,代码行数:30,代码来源:password_policy_validators.py

示例3: test_disabled_too_frequent_password_resets

# 需要导入模块: from student.models import PasswordHistory [as 别名]
# 或者: from student.models.PasswordHistory import is_password_reset_too_soon [as 别名]
    def test_disabled_too_frequent_password_resets(self):
        """
        Verify properly default behavior when feature is disabled
        """
        student = self._user_factory_with_history()

        self.assertFalse(PasswordHistory.is_password_reset_too_soon(student))
开发者ID:10clouds,项目名称:edx-platform,代码行数:9,代码来源:test_password_history.py


注:本文中的student.models.PasswordHistory.is_password_reset_too_soon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。