コード例 #1
0
def email_admins_on_user_locked_out(cache_key, ip_address):
    """Email admins on user locked out."""
    cache = get_cache()
    key = f"{cache_key}-notified"
    lockout_email_sent = cache.get(key, False)
    if not lockout_email_sent:
        cache.set(key, True, get_cache_timeout())
        context = {
            "ip_address": ip_address,
            "time": now(),
            "project_name": settings.PROJECT_NAME,
        }
        mail_admins(
            subject="A lockout has occured",
            message=render_to_string("axes/lockout_admin_email.txt",
                                     context=context),
            html_message=render_to_string("axes/lockout_admin_email.html",
                                          context=context),
        )
コード例 #2
0
 def __init__(self):
     self.cache = get_cache()
     self.cache_timeout = get_cache_timeout()
コード例 #3
0
ファイル: test_login.py プロジェクト: Sidneyasjr/blog_django
 def reset(self, **kwargs):
     get_cache().delete(make_cache_key_list([kwargs])[0])
コード例 #4
0
ファイル: test_login.py プロジェクト: Sidneyasjr/blog_django
 def attempt_count(self):
     cache = get_cache()
     keys = cache._cache
     return len(keys)
コード例 #5
0
 def tearDown(self):
     get_cache().clear()
コード例 #6
0
ファイル: cache.py プロジェクト: jazzband/django-axes
 def __init__(self):
     self.cache = get_cache()
     self.cache_timeout = get_cache_timeout()
コード例 #7
0
ファイル: base.py プロジェクト: jazzband/django-axes
 def tearDown(self):
     get_cache().clear()