mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-01 20:27:02 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Mixins for authentication views.
|
||||
"""
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from apps.core.utils.turnstile import get_client_ip, validate_turnstile_token
|
||||
@@ -24,14 +25,14 @@ class TurnstileMixin:
|
||||
token = None
|
||||
|
||||
# Check POST data (form submissions)
|
||||
if hasattr(request, 'POST'):
|
||||
if hasattr(request, "POST"):
|
||||
token = request.POST.get("cf-turnstile-response")
|
||||
|
||||
# Check JSON body (API requests)
|
||||
if not token and hasattr(request, 'data'):
|
||||
data = getattr(request, 'data', {})
|
||||
if hasattr(data, 'get'):
|
||||
token = data.get('turnstile_token') or data.get('cf-turnstile-response')
|
||||
if not token and hasattr(request, "data"):
|
||||
data = getattr(request, "data", {})
|
||||
if hasattr(data, "get"):
|
||||
token = data.get("turnstile_token") or data.get("cf-turnstile-response")
|
||||
|
||||
# Get client IP
|
||||
ip = get_client_ip(request)
|
||||
@@ -39,6 +40,6 @@ class TurnstileMixin:
|
||||
# Validate the token
|
||||
result = validate_turnstile_token(token, ip)
|
||||
|
||||
if not result.get('success'):
|
||||
error_msg = result.get('error', 'Captcha verification failed. Please try again.')
|
||||
if not result.get("success"):
|
||||
error_msg = result.get("error", "Captcha verification failed. Please try again.")
|
||||
raise ValidationError(error_msg)
|
||||
|
||||
Reference in New Issue
Block a user