Bypass Turnstile validation when DEBUG is True

This commit is contained in:
pacnpal
2024-11-13 16:10:25 +00:00
parent ec626b4124
commit 97a3555e81

View File

@@ -5,11 +5,16 @@ from django.core.exceptions import ValidationError
class TurnstileMixin:
"""
Mixin to handle Cloudflare Turnstile validation.
Bypasses validation when DEBUG is True.
"""
def validate_turnstile(self, request):
"""
Validate the Turnstile response token.
Skips validation when DEBUG is True.
"""
if settings.DEBUG:
return
token = request.POST.get('cf-turnstile-response')
if not token:
raise ValidationError('Please complete the Turnstile challenge.')