|
6 | 6 | import waffle |
7 | 7 | from waffle import get_waffle_flag_model |
8 | 8 |
|
9 | | -from django.http.response import HttpResponse, HttpResponseBadRequest |
| 9 | +from django.http.response import HttpResponse, HttpResponseBadRequest, JsonResponse |
10 | 10 | from django.template.response import TemplateResponse |
11 | 11 | from django.utils.decorators import method_decorator |
12 | 12 | from django.views.decorators.csrf import csrf_exempt |
|
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 as http_status |
24 | 25 | from urllib.parse import urlparse, parse_qs |
25 | 26 | import html |
26 | 27 | from apps.dot_ext.scopes import CapabilitiesScopes |
@@ -184,7 +185,20 @@ def form_valid(self, form): |
184 | 185 | refresh_token_delete_cnt) = remove_application_user_pair_tokens_data_access(application, self.request.user) |
185 | 186 |
|
186 | 187 | if not scopes: |
187 | | - return self.error_response("No scopes", application) |
| 188 | + beneficiary_authorized_application.send( |
| 189 | + sender=self, |
| 190 | + request=self.request, |
| 191 | + auth_status="FAIL", |
| 192 | + auth_status_code=http_status.HTTP_400_BAD_REQUEST, |
| 193 | + user=self.request.user, |
| 194 | + application=application, |
| 195 | + share_demographic_scopes=share_demographic_scopes, |
| 196 | + scopes=scopes, |
| 197 | + allow=allow, |
| 198 | + access_token_delete_cnt=access_token_delete_cnt, |
| 199 | + refresh_token_delete_cnt=refresh_token_delete_cnt, |
| 200 | + data_access_grant_delete_cnt=data_access_grant_delete_cnt) |
| 201 | + return JsonResponse({"error": 'The state parameter is required'}, status=http_status.HTTP_400_BAD_REQUEST) |
188 | 202 | try: |
189 | 203 | uri, headers, body, status = self.create_authorization_response( |
190 | 204 | request=self.request, scopes=scopes, credentials=credentials, allow=allow |
|
0 commit comments