API ISsues fixes pluigna dn app, plugin v udapte 1.4.0
This commit is contained in:
@@ -128,8 +128,7 @@ class IntegrationViewSet(SiteSectorModelViewSet):
|
||||
return True
|
||||
|
||||
@extend_schema(tags=['Integration'])
|
||||
@action(detail=False, methods=['post'], url_path='test-connection',
|
||||
permission_classes=[AllowAny], throttle_classes=[NoThrottle])
|
||||
@action(detail=False, methods=['post'], url_path='test-connection')
|
||||
def test_connection_collection(self, request):
|
||||
"""
|
||||
Test WordPress connection using Site.wp_api_key (single source of truth).
|
||||
@@ -161,14 +160,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 hasattr(request, 'user') or not getattr(request.user, 'is_authenticated', False):
|
||||
return error_response('Authentication required', None, status.HTTP_403_FORBIDDEN, request)
|
||||
if not request.user or not request.user.is_authenticated:
|
||||
return error_response('Authentication required', None, status.HTTP_401_UNAUTHORIZED, 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)
|
||||
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)
|
||||
|
||||
# Get stored API key from Site model (single source of truth)
|
||||
stored_api_key = site.wp_api_key
|
||||
|
||||
Reference in New Issue
Block a user