updates
This commit is contained in:
@@ -62,6 +62,15 @@ class ContactSubmissionViewSet(viewsets.ModelViewSet):
|
||||
permission_classes = [IsAuthenticated]
|
||||
return [permission() for permission in permission_classes]
|
||||
|
||||
def get_authenticators(self):
|
||||
"""
|
||||
Override authentication for create action to bypass CSRF.
|
||||
By returning an empty list, DRF won't enforce CSRF for this action.
|
||||
"""
|
||||
if hasattr(self, 'action') and self.action == 'create':
|
||||
return []
|
||||
return super().get_authenticators()
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
"""
|
||||
Create a new contact submission.
|
||||
@@ -259,4 +268,4 @@ class ContactSubmissionViewSet(viewsets.ModelViewSet):
|
||||
return Response({
|
||||
'error': 'Failed to send test email',
|
||||
'status': 'error'
|
||||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
Reference in New Issue
Block a user