Skip to content

Commit 9dc45de

Browse files
committed
skip auth prompting only if scopes are the same as previous authorization
1 parent 46af6cd commit 9dc45de

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

oauth2_provider/views/base.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,16 @@ def get(self, request, *args, **kwargs):
117117
# Check to see if the user has already granted access and return
118118
# a successful response
119119
require_approval = request.GET.get('approval_prompt', 'force')
120-
if require_approval == 'auto' and request.user.accesstoken_set.filter(
121-
application=kwargs['application'],
122-
expires__gt=timezone.now()).count():
123-
uri, headers, body, status = self.create_authorization_response(
124-
request=self.request, scopes=" ".join(scopes),
125-
credentials=credentials, allow=True)
126-
self.success_url = uri
127-
return HttpResponseRedirect(self.success_url)
120+
if require_approval == 'auto':
121+
tokens = request.user.accesstoken_set.filter(application=kwargs['application'],
122+
expires__gt=timezone.now()).all()
123+
for token in tokens:
124+
if token.allow_scopes(scopes):
125+
uri, headers, body, status = self.create_authorization_response(
126+
request=self.request, scopes=" ".join(scopes),
127+
credentials=credentials, allow=True)
128+
return HttpResponseRedirect(uri)
129+
128130
return self.render_to_response(self.get_context_data(**kwargs))
129131

130132
except OAuthToolkitError as error:

0 commit comments

Comments
 (0)