|
21 | 21 | ) |
22 | 22 | from oauth2_provider.models import get_application_model |
23 | 23 | from oauthlib.oauth2.rfc6749.errors import InvalidClientError, InvalidGrantError |
24 | | -from rest_framework import status |
25 | 24 | from urllib.parse import urlparse, parse_qs |
26 | 25 | import html |
27 | 26 | from apps.dot_ext.scopes import CapabilitiesScopes |
@@ -366,29 +365,27 @@ def post(self, request, *args, **kwargs): |
366 | 365 | except (InvalidClientError, InvalidGrantError) as error: |
367 | 366 | return json_response_from_oauth2_error(error) |
368 | 367 |
|
369 | | - try: |
370 | | - tkn = json.loads(request.body.decode("UTF-8")).get("token") |
371 | | - except Exception: |
372 | | - tkn = request.POST.get("token") |
373 | | - |
374 | | - escaped_tkn = html.escape(tkn) |
| 368 | + tkn = request.POST.get('token') |
| 369 | + if tkn is not None: |
| 370 | + escaped_tkn = html.escape(tkn) |
| 371 | + else: |
| 372 | + escaped_tkn = "" |
375 | 373 |
|
376 | 374 | try: |
377 | 375 | token = at_model.objects.get(token=tkn) |
378 | 376 | except at_model.DoesNotExist: |
379 | | - return HttpResponse(f"Token {escaped_tkn} was Not Found. Please check the value and try again.", |
380 | | - status=status.HTTP_404_NOT_FOUND) |
| 377 | + log.debug(f"Token {escaped_tkn} was not found.") |
381 | 378 |
|
382 | 379 | try: |
383 | 380 | dag = DataAccessGrant.objects.get( |
384 | 381 | beneficiary=token.user, |
385 | 382 | application=app |
386 | 383 | ) |
387 | 384 | dag.delete() |
388 | | - except DataAccessGrant.DoesNotExist: |
389 | | - log.debug(f"Token deleted, but DAG lookup failed for token {escaped_tkn}.") |
| 385 | + except Exception: |
| 386 | + log.debug(f"DAG lookup failed for token {escaped_tkn}.") |
390 | 387 |
|
391 | | - return HttpResponse(content="OK", status=200) |
| 388 | + return super().post(request, args, kwargs) |
392 | 389 |
|
393 | 390 |
|
394 | 391 | @method_decorator(csrf_exempt, name="dispatch") |
|
0 commit comments