mirror of
https://github.com/jazzband/django-axes.git
synced 2026-05-18 20:41:09 +00:00
factor lockout_response into its own helper function
This commit is contained in:
parent
aa1bc1456b
commit
58453048a9
1 changed files with 19 additions and 16 deletions
|
|
@ -97,26 +97,29 @@ def watch_login(func):
|
|||
if check_request(request, login_unsuccessful):
|
||||
return response
|
||||
|
||||
if LOCKOUT_TEMPLATE:
|
||||
context = RequestContext(request, {
|
||||
'cooloff_time': COOLOFF_TIME,
|
||||
'failure_limit': FAILURE_LIMIT,
|
||||
})
|
||||
return render_to_response(LOCKOUT_TEMPLATE, context)
|
||||
|
||||
if LOCKOUT_URL:
|
||||
return HttpResponseRedirect(LOCKOUT_URL)
|
||||
|
||||
if COOLOFF_TIME:
|
||||
return HttpResponse("Account locked: too many login attempts. "
|
||||
"Please try again later.")
|
||||
else:
|
||||
return HttpResponse("Account locked: too many login attempts. "
|
||||
"Contact an admin to unlock your account.")
|
||||
return lockout_response(request)
|
||||
return response
|
||||
|
||||
return decorated_login
|
||||
|
||||
def lockout_response(request):
|
||||
if LOCKOUT_TEMPLATE:
|
||||
context = RequestContext(request, {
|
||||
'cooloff_time': COOLOFF_TIME,
|
||||
'failure_limit': FAILURE_LIMIT,
|
||||
})
|
||||
return render_to_response(LOCKOUT_TEMPLATE, context)
|
||||
|
||||
if LOCKOUT_URL:
|
||||
return HttpResponseRedirect(LOCKOUT_URL)
|
||||
|
||||
if COOLOFF_TIME:
|
||||
return HttpResponse("Account locked: too many login attempts. "
|
||||
"Please try again later.")
|
||||
else:
|
||||
return HttpResponse("Account locked: too many login attempts. "
|
||||
"Contact an admin to unlock your account.")
|
||||
|
||||
def check_request(request, login_unsuccessful):
|
||||
failures = 0
|
||||
attempt = get_user_attempt(request)
|
||||
|
|
|
|||
Loading…
Reference in a new issue