Skip to content

Commit 2a13b98

Browse files
Aristobulo Menesesjleclanche
authored andcommitted
Fix AuthorizationView.get method
As user.accesstoken is not accesible anymore since it refers to %(app_label)s_%(class)s from the swapped model, tokens must be queried by filtering on get_access_token_model() and use request.user
1 parent bb6c890 commit 2a13b98

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

oauth2_provider/views/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ..exceptions import OAuthToolkitError
1313
from ..forms import AllowForm
1414
from ..http import HttpResponseUriRedirect
15-
from ..models import get_application_model
15+
from ..models import get_access_token_model, get_application_model
1616
from ..scopes import get_scopes_backend
1717
from ..settings import oauth2_settings
1818

@@ -146,8 +146,12 @@ def get(self, request, *args, **kwargs):
146146
return HttpResponseUriRedirect(uri)
147147

148148
elif require_approval == 'auto':
149-
tokens = request.user.accesstoken_set.filter(application=kwargs['application'],
150-
expires__gt=timezone.now()).all()
149+
tokens = get_access_token_model().objects.filter(
150+
user=request.user,
151+
application=kwargs["application"],
152+
expires__gt=timezone.now()
153+
).all()
154+
151155
# check past authorizations regarded the same scopes as the current one
152156
for token in tokens:
153157
if token.allow_scopes(scopes):

0 commit comments

Comments
 (0)