From 54988a928d37fc12e1f6eb83c6ecfc2babe55e29 Mon Sep 17 00:00:00 2001 From: Bobby Date: Wed, 28 Dec 2022 07:51:38 -0500 Subject: Registraion function with captcha working --- ignis/urls.py | 1 + ignis/views.py | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'ignis') 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//', views.get_image, name='get_image'), path('/cover/', views.cover_image, name='cover_image'), + path('/captcha/', 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') + -- cgit v1.2.3