|
20 | 20 | IntrospectTokenView as DotIntrospectTokenView, |
21 | 21 | ) |
22 | 22 | from oauth2_provider.models import get_application_model |
23 | | -from oauthlib.oauth2 import AccessDeniedError |
| 23 | +from oauthlib import oauth2 |
24 | 24 | from oauthlib.oauth2.rfc6749.errors import InvalidClientError, InvalidGrantError |
25 | 25 | from urllib.parse import urlparse, parse_qs |
26 | 26 | import html |
@@ -179,33 +179,20 @@ def form_valid(self, form): |
179 | 179 | access_token_delete_cnt = 0 |
180 | 180 | refresh_token_delete_cnt = 0 |
181 | 181 |
|
182 | | - if allow is False: |
183 | | - (data_access_grant_delete_cnt, |
184 | | - access_token_delete_cnt, |
185 | | - refresh_token_delete_cnt) = remove_application_user_pair_tokens_data_access(application, self.request.user) |
186 | | - |
187 | | - if not scopes: |
188 | | - beneficiary_authorized_application.send( |
189 | | - sender=self, |
190 | | - request=self.request, |
191 | | - auth_status="FAIL", |
192 | | - auth_status_code=302, |
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 | | - raise AccessDeniedError(state=credentials.get("state", None)) |
202 | 182 | try: |
203 | 183 | uri, headers, body, status = self.create_authorization_response( |
204 | 184 | request=self.request, scopes=scopes, credentials=credentials, allow=allow |
205 | 185 | ) |
| 186 | + if not scopes: |
| 187 | + raise oauth2.AccessDeniedError(state=credentials.get("state", None)) |
206 | 188 | except OAuthToolkitError as error: |
207 | 189 | response = self.error_response(error, application) |
208 | 190 |
|
| 191 | + if allow is False: |
| 192 | + (data_access_grant_delete_cnt, |
| 193 | + access_token_delete_cnt, |
| 194 | + refresh_token_delete_cnt) = remove_application_user_pair_tokens_data_access(application, self.request.user) |
| 195 | + |
209 | 196 | beneficiary_authorized_application.send( |
210 | 197 | sender=self, |
211 | 198 | request=self.request, |
|
0 commit comments