@@ -178,11 +178,10 @@ def form_valid(self, form):
178178 access_token_delete_cnt = 0
179179 refresh_token_delete_cnt = 0
180180
181- # Did the beneficiary choose not to share demographic scopes, or the application does not require them?
182- if share_demographic_scopes == "False" or (allow is True and application .require_demographic_scopes is False ):
181+ if allow is False :
183182 (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 )
183+ access_token_delete_cnt ,
184+ refresh_token_delete_cnt ) = remove_application_user_pair_tokens_data_access (application , self .request .user )
186185
187186 if not scopes :
188187 return self .error_response ("No scopes" , application )
@@ -193,11 +192,6 @@ def form_valid(self, form):
193192 except OAuthToolkitError as error :
194193 response = self .error_response (error , application )
195194
196- if allow is False :
197- (data_access_grant_delete_cnt ,
198- access_token_delete_cnt ,
199- refresh_token_delete_cnt ) = remove_application_user_pair_tokens_data_access (application , self .request .user )
200-
201195 beneficiary_authorized_application .send (
202196 sender = self ,
203197 request = self .request ,
@@ -213,6 +207,12 @@ def form_valid(self, form):
213207 data_access_grant_delete_cnt = data_access_grant_delete_cnt )
214208 return response
215209
210+ # Did the beneficiary choose not to share demographic scopes, or the application does not require them?
211+ if share_demographic_scopes == "False" or (allow is True and application .require_demographic_scopes is False ):
212+ (data_access_grant_delete_cnt ,
213+ access_token_delete_cnt ,
214+ refresh_token_delete_cnt ) = remove_application_user_pair_tokens_data_access (application , self .request .user )
215+
216216 beneficiary_authorized_application .send (
217217 sender = self ,
218218 request = self .request ,
0 commit comments