This commit is contained in:
alorig
2025-11-22 20:20:32 +05:00
parent 8510b87a67
commit 6e25c5e307
4 changed files with 155 additions and 2 deletions

View File

@@ -135,6 +135,22 @@ class IntegrationViewSet(SiteSectorModelViewSet):
stored_key = getattr(site, 'wp_api_key', None)
if stored_key and api_key and str(api_key) == str(stored_key):
authenticated = True
elif not stored_key:
# API key not set on site - provide helpful error message
return error_response(
'API key not configured for this site. Please generate an API key in the IGNY8 app and ensure it is saved to the site.',
None,
status.HTTP_403_FORBIDDEN,
request
)
elif api_key and stored_key and str(api_key) != str(stored_key):
# API key provided but doesn't match
return error_response(
'Invalid API key. The provided API key does not match the one stored for this site.',
None,
status.HTTP_403_FORBIDDEN,
request
)
if not authenticated:
return error_response('Authentication credentials were not provided.', None, status.HTTP_403_FORBIDDEN, request)