django-axes/axes/decorators.py
Aleksi Häkli ff6cb8bffd
Move utils to helpers module
In order to offer backwards compatible import path for the
axes.utils.reset function it has to have a separate
implementation that can be imported independently from
the axes.helpers functions that are used by the
AxesBaseHandler implementation.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-25 22:54:40 +02:00

26 lines
612 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