mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
parent
491b7f2381
commit
50a6baae2a
1 changed files with 19 additions and 0 deletions
|
|
@ -154,3 +154,22 @@ into ``my_namespace-username``:
|
|||
authenticate. If you want to re-use the same function for consistency, that's
|
||||
fine, but Axes does not inject these changes into the authentication flow
|
||||
for you.
|
||||
|
||||
|
||||
Customizing lockout responses
|
||||
-----------------------------
|
||||
|
||||
Axes can be configured with ``AXES_LOCKOUT_CALLABLE`` to return a custom lockout response when using the plugin with e.g. DRF (Django REST Framework) or other third party libraries which require specialized formats such as JSON or XML response formats or customized response status codes.
|
||||
|
||||
An example of usage could be e.g. a custom view for processing lockouts.
|
||||
|
||||
``example/views.py``::
|
||||
|
||||
from django.http import JsonResponse
|
||||
|
||||
def lockout(request, credentials, *args, **kwargs):
|
||||
return JsonResponse({"status": "Locked out due to too many login failures"}, status=403)
|
||||
|
||||
``settings.py``::
|
||||
|
||||
AXES_LOCKOUT_CALLABLE = "example.views.lockout"
|
||||
|
|
|
|||
Loading…
Reference in a new issue