2017-11-21 21:51:59 +00:00
|
|
|
from functools import wraps
|
2010-10-18 03:38:42 +00:00
|
|
|
|
2019-02-17 21:56:48 +00:00
|
|
|
from axes.handlers.proxy import AxesProxyHandler
|
2019-02-25 20:54:40 +00:00
|
|
|
from axes.helpers import get_lockout_response
|
2017-07-20 14:06:41 +00:00
|
|
|
|
2014-05-24 11:48:39 +00:00
|
|
|
|
2017-11-21 21:51:59 +00:00
|
|
|
def axes_dispatch(func):
|
2021-01-05 09:00:13 +00:00
|
|
|
@wraps(func)
|
2019-05-19 12:54:27 +00:00
|
|
|
def inner(request, *args, **kwargs):
|
2019-02-22 18:13:20 +00:00
|
|
|
if AxesProxyHandler.is_allowed(request):
|
2019-02-17 21:56:48 +00:00
|
|
|
return func(request, *args, **kwargs)
|
2012-08-26 06:36:52 +00:00
|
|
|
|
2019-02-17 21:56:48 +00:00
|
|
|
return get_lockout_response(request)
|
2008-11-05 22:52:40 +00:00
|
|
|
|
2017-07-20 14:06:41 +00:00
|
|
|
return inner
|
2010-09-15 04:39:35 +00:00
|
|
|
|
2011-04-12 21:04:51 +00:00
|
|
|
|
2017-11-21 21:51:59 +00:00
|
|
|
def axes_form_invalid(func):
|
|
|
|
|
@wraps(func)
|
|
|
|
|
def inner(self, *args, **kwargs):
|
2019-02-22 18:13:20 +00:00
|
|
|
if AxesProxyHandler.is_allowed(self.request):
|
2019-02-17 21:56:48 +00:00
|
|
|
return func(self, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
return get_lockout_response(self.request)
|
2017-11-21 21:51:59 +00:00
|
|
|
|
|
|
|
|
return inner
|