aboutsummaryrefslogtreecommitdiff
path: root/ignis
diff options
context:
space:
mode:
authorBobby <[email protected]>2022-12-28 07:51:38 -0500
committerBobby <[email protected]>2022-12-28 07:51:38 -0500
commit54988a928d37fc12e1f6eb83c6ecfc2babe55e29 (patch)
tree42f5a62061fc3b0a4e70484d6bfb4afe184224d1 /ignis
parent3ff3acef57e95ecd2e8dde429d4735e7c2e8e684 (diff)
downloadthatcomputerscientist-54988a928d37fc12e1f6eb83c6ecfc2babe55e29.tar.xz
thatcomputerscientist-54988a928d37fc12e1f6eb83c6ecfc2babe55e29.zip
Registraion function with captcha working
Diffstat (limited to 'ignis')
-rw-r--r--ignis/urls.py1
-rw-r--r--ignis/views.py8
2 files changed, 9 insertions, 0 deletions
diff --git a/ignis/urls.py b/ignis/urls.py
index b190a40f..44ed5de1 100644
--- a/ignis/urls.py
+++ b/ignis/urls.py
@@ -8,4 +8,5 @@ urlpatterns = [
path('/upload', views.upload_image, name='upload_image'),
path('/image/<post_id>/<image_name>', views.get_image, name='get_image'),
path('/cover/<str:repository>', views.cover_image, name='cover_image'),
+ path('/captcha/<str:captcha_string>', views.captcha_image, name='captcha_image')
]
diff --git a/ignis/views.py b/ignis/views.py
index 1e822cbf..211346eb 100644
--- a/ignis/views.py
+++ b/ignis/views.py
@@ -9,6 +9,8 @@ from .models import PostImage, RepositoryTitle
import json
import requests
from django.core.files.base import ContentFile
+from captcha.image import ImageCaptcha
+from users.tokens import CaptchaTokenGenerator
# from .github import get_cover
# Create your views here.
@@ -134,3 +136,9 @@ def upload_image(request):
return HttpResponse(json.dumps(response), content_type='application/json')
return HttpResponse('Method not allowed', status=405)
+def captcha_image(request, captcha_string):
+ captcha = CaptchaTokenGenerator().decrypt(captcha_string)
+ imgcaptcha = ImageCaptcha()
+ data = imgcaptcha.generate(captcha)
+ return HttpResponse(data, content_type='image/png')
+