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: class TurnstileMixin:
""" """
Mixin to handle Cloudflare Turnstile validation. Mixin to handle Cloudflare Turnstile validation.
Bypasses validation when DEBUG is True.
""" """
def validate_turnstile(self, request): def validate_turnstile(self, request):
""" """
Validate the Turnstile response token. Validate the Turnstile response token.
Skips validation when DEBUG is True.
""" """
if settings.DEBUG:
return
token = request.POST.get('cf-turnstile-response') token = request.POST.get('cf-turnstile-response')
if not token: if not token:
raise ValidationError('Please complete the Turnstile challenge.') raise ValidationError('Please complete the Turnstile challenge.')