Revert "API ISsues fixes pluigna dn app, plugin v udapte 1.4.0"

This reverts commit a361dea528.
This commit is contained in:
IGNY8 VPS (Salman)
2026-01-13 05:26:32 +00:00
parent a361dea528
commit 6f64d359fb
9 changed files with 27 additions and 728 deletions

View File

@@ -128,7 +128,8 @@ class IntegrationViewSet(SiteSectorModelViewSet):
return True
@extend_schema(tags=['Integration'])
@action(detail=False, methods=['post'], url_path='test-connection')
@action(detail=False, methods=['post'], url_path='test-connection',
permission_classes=[AllowAny], throttle_classes=[NoThrottle])
def test_connection_collection(self, request):
"""
Test WordPress connection using Site.wp_api_key (single source of truth).
@@ -160,14 +161,14 @@ class IntegrationViewSet(SiteSectorModelViewSet):
return error_response('Site not found or invalid', None, status.HTTP_404_NOT_FOUND, request)
# Authentication: user must be authenticated and belong to same account
if not request.user or not request.user.is_authenticated:
return error_response('Authentication required', None, status.HTTP_401_UNAUTHORIZED, request)
if not hasattr(request, 'user') or not getattr(request.user, 'is_authenticated', False):
return error_response('Authentication required', None, status.HTTP_403_FORBIDDEN, request)
if not hasattr(request.user, 'account') or not request.user.account:
return error_response('User account not found', None, status.HTTP_403_FORBIDDEN, request)
if site.account_id != request.user.account_id:
return error_response('Site does not belong to your account', None, status.HTTP_403_FORBIDDEN, request)
try:
if site.account != request.user.account:
return error_response('Site does not belong to your account', None, status.HTTP_403_FORBIDDEN, request)
except Exception:
return error_response('Authentication failed', None, status.HTTP_403_FORBIDDEN, request)
# Get stored API key from Site model (single source of truth)
stored_api_key = site.wp_api_key