Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions captcha/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import subprocess
import six
from ratelimit.decorators import ratelimit

try:
from cStringIO import StringIO
Expand Down Expand Up @@ -40,7 +41,7 @@ def makeimg(size):
image = Image.new("RGB", size, settings.CAPTCHA_BACKGROUND_COLOR)
return image


@ratelimit(key='ip', rate='1/s',block=True)
def captcha_image(request, key, scale=1):
try:
store = CaptchaStore.objects.get(hashkey=key)
Expand Down Expand Up @@ -136,7 +137,7 @@ def captcha_image(request, key, scale=1):

return response


@ratelimit(key='ip', rate='1/s',block=True)
def captcha_audio(request, key):
if settings.CAPTCHA_FLITE_PATH:
try:
Expand Down Expand Up @@ -200,7 +201,7 @@ def captcha_audio(request, key):
return response
raise Http404


@ratelimit(key='ip', rate='1/s',block=True)
def captcha_refresh(request):
""" Return json with new captcha for ajax refresh request """
if not request.is_ajax():
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def run_tests(self):
"six >=1.2.0",
"Django >= 1.8",
"Pillow >=6.2.0",
"django-ratelimit>=2.0.0",
"django-ranged-response == 0.2.0",
]
EXTRAS_REQUIRE = {"test": ("testfixtures",)}
Expand Down