345
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user