mirror of
https://github.com/jazzband/django-defender.git
synced 2026-03-16 22:10:32 +00:00
Added changes and fixed small bug
This commit is contained in:
parent
177f2ecce8
commit
bbe7687abd
2 changed files with 7 additions and 2 deletions
|
|
@ -3,6 +3,8 @@ Changes
|
||||||
=======
|
=======
|
||||||
|
|
||||||
- Confirm support for Django 4.1
|
- Confirm support for Django 4.1
|
||||||
|
- Add ``DEFENDER_ATTEMPT_COOLOFF_TIME`` config to override ``DEFENDER_COOLOFF_TIME`` specifically for attempt lifespan [@djmore4]
|
||||||
|
- Add ``DEFENDER_LOCKOUT_COOLOFF_TIME`` config to override ``DEFENDER_COOLOFF_TIME`` specifically for lockout duration [@djmore4]
|
||||||
|
|
||||||
0.9.5
|
0.9.5
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
from ipaddress import ip_address
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
@ -340,8 +341,10 @@ def reset_failed_attempts(ip_address=None, username=None):
|
||||||
|
|
||||||
def lockout_response(request):
|
def lockout_response(request):
|
||||||
""" if we are locked out, here is the response """
|
""" if we are locked out, here is the response """
|
||||||
|
ip_address = get_ip(request)
|
||||||
|
username = get_username_from_request(request)
|
||||||
if config.LOCKOUT_TEMPLATE:
|
if config.LOCKOUT_TEMPLATE:
|
||||||
cooloff_time = get_lockout_cooloff_time(ip_address=get_ip(request), username=get_username_from_request(request))
|
cooloff_time = get_lockout_cooloff_time(ip_address=ip_address, username=username)
|
||||||
context = {
|
context = {
|
||||||
"cooloff_time_seconds": cooloff_time,
|
"cooloff_time_seconds": cooloff_time,
|
||||||
"cooloff_time_minutes": cooloff_time / 60,
|
"cooloff_time_minutes": cooloff_time / 60,
|
||||||
|
|
@ -352,7 +355,7 @@ def lockout_response(request):
|
||||||
if config.LOCKOUT_URL:
|
if config.LOCKOUT_URL:
|
||||||
return HttpResponseRedirect(config.LOCKOUT_URL)
|
return HttpResponseRedirect(config.LOCKOUT_URL)
|
||||||
|
|
||||||
if get_lockout_cooloff_time():
|
if get_lockout_cooloff_time(ip_address=ip_address, username=username):
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
"Account locked: too many login attempts. " "Please try again later."
|
"Account locked: too many login attempts. " "Please try again later."
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue