mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
The old architecture used exceptions in the signal handler which prevented transactions from running smoothly and signal handlers from running after Axes handlers. The new architecture changes the request approach to request flagging and moves the exception handling into the middleware call method. This allows users to more flexibly run their own signal handlers and optionally use the Axes middleware if they want to do so. Fixes #440 Fixes #442
25 lines
611 B
Python
25 lines
611 B
Python
from functools import wraps
|
|
|
|
from axes.handlers.proxy import AxesProxyHandler
|
|
from axes.helpers import get_lockout_response
|
|
|
|
|
|
def axes_dispatch(func):
|
|
def inner(request, *args, **kwargs):
|
|
if AxesProxyHandler.is_allowed(request):
|
|
return func(request, *args, **kwargs)
|
|
|
|
return get_lockout_response(request)
|
|
|
|
return inner
|
|
|
|
|
|
def axes_form_invalid(func):
|
|
@wraps(func)
|
|
def inner(self, *args, **kwargs):
|
|
if AxesProxyHandler.is_allowed(self.request):
|
|
return func(self, *args, **kwargs)
|
|
|
|
return get_lockout_response(self.request)
|
|
|
|
return inner
|