mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 06:29:31 -02:30
* fixes UnboundLocalError in POST /attach * bust cache for credentials before attaching subscription --------- Signed-off-by: Robin Y Bobbitt <rbobbitt@redhat.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import operator
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.cache import cache
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||||
@@ -239,8 +240,12 @@ class ApiV2AttachView(APIView):
|
|||||||
subscription_id = data.get('subscription_id', None)
|
subscription_id = data.get('subscription_id', None)
|
||||||
if not subscription_id:
|
if not subscription_id:
|
||||||
return Response({"error": _("No subscription ID provided.")}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({"error": _("No subscription ID provided.")}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
# Ensure we always use the latest subscription credentials
|
||||||
|
cache.delete_many(['SUBSCRIPTIONS_CLIENT_ID', 'SUBSCRIPTIONS_CLIENT_SECRET'])
|
||||||
user = getattr(settings, 'SUBSCRIPTIONS_CLIENT_ID', None)
|
user = getattr(settings, 'SUBSCRIPTIONS_CLIENT_ID', None)
|
||||||
pw = getattr(settings, 'SUBSCRIPTIONS_CLIENT_SECRET', None)
|
pw = getattr(settings, 'SUBSCRIPTIONS_CLIENT_SECRET', None)
|
||||||
|
if not (user and pw):
|
||||||
|
return Response({"error": _("Missing subscription credentials")}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
if subscription_id and user and pw:
|
if subscription_id and user and pw:
|
||||||
data = request.data.copy()
|
data = request.data.copy()
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user