decrease captcha dots

This commit is contained in:
2025-05-28 16:26:01 +03:30
parent c3c13ef21e
commit 821a33d0f6
2 changed files with 13 additions and 2 deletions

View File

@@ -147,7 +147,7 @@ class UserViewSet(ModelViewSet):
url_name='profile',
url_path='profile',
name='profile',
permission_classes=[AllowAny]
# permission_classes=[AllowAny]
)
def profile(self, request):
serializer = authorize_view.UserRelationSerializer(

View File

@@ -1,3 +1,5 @@
import random
from rest_captcha import utils
from rest_captcha.settings import api_settings
from django.core.cache import caches
@@ -5,6 +7,15 @@ from django.core.cache import caches
cache = caches[api_settings.CAPTCHA_CACHE]
def noise_dots(draw, image, fill):
size = image.size
for p in range(int(size[0] * size[1] * 0.07)):
x = random.randint(0, size[0])
y = random.randint(0, size[1])
draw.point((x, y), fill=fill)
return draw
def noise_default(image, draw):
draw = utils.noise_dots(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)
draw = noise_dots(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)
# draw = utils.noise_arcs(draw, image, api_settings.CAPTCHA_FOREGROUND_COLOR)