@@ -92,7 +92,6 @@ class AuthorizationView(DotAuthorizationView):
9292 # this needs to be here for urls.py as_view(version) calls, but don't use it
9393 version = 0
9494 # Variable to help reduce the amount of times validate_v3_authorization_request is called
95- validate_v3_call = True
9695 form_class = SimpleAllowForm
9796 login_url = "/mymedicare/login"
9897
@@ -154,7 +153,7 @@ def dispatch(self, request, *args, **kwargs):
154153 path_info = self .request .__dict__ .get ('path_info' )
155154 version = get_api_version_number_from_url (path_info )
156155 # If it is not version 3, we don't need to check anything, just return
157- if version == Versions .V3 and self . validate_v3_call :
156+ if version == Versions .V3 :
158157 self .validate_v3_authorization_request ()
159158 # TODO: Should the client_id match a valid application here before continuing, instead of after matching to FHIR_ID?
160159 if not kwargs .get ('is_subclass_approvalview' , False ):
@@ -252,17 +251,14 @@ def validate_v3_authorization_request(self):
252251 if flag .id is None or flag .is_active_for_user (application_user ):
253252 # Update the class variable to ensure subsequent calls to dispatch don't call this function
254253 # more times than is needed
255- self .validate_v3_call = False
256254 return
257255 else :
258256 raise AccessDeniedTokenCustomError (
259257 description = settings .APPLICATION_DOES_NOT_HAVE_V3_ENABLED_YET .format (application .name )
260258 )
261259 except ObjectDoesNotExist :
262- # 4250-TODO Do we need this?
263- return JsonResponse (
264- {'status_code' : 500 , 'message' : 'Error retrieving data' },
265- status = 500 ,
260+ raise AccessDeniedTokenCustomError (
261+ description = 'You do not have permission to perform this action.'
266262 )
267263
268264 def form_valid (self , form ):
@@ -469,10 +465,9 @@ def validate_v3_token_call(self, request) -> None:
469465 settings .APPLICATION_DOES_NOT_HAVE_V3_ENABLED_YET .format (application .name )
470466 )
471467 except ObjectDoesNotExist :
472- # 4250-TODO Do we need this?
473468 return JsonResponse (
474- {'status_code' : 500 , 'message' : 'Error retrieving data ' },
475- status = 500 ,
469+ {'status_code' : 403 , 'message' : 'You do not have permission to perform this action. ' },
470+ status = 403 ,
476471 )
477472
478473 @method_decorator (sensitive_post_parameters ("password" ))
0 commit comments