mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Fix bug with inactive user accessing OAuth
This commit is contained in:
parent
399ac70b83
commit
74fbd5ccc5
|
@ -10,7 +10,7 @@ from django.core.exceptions import ImproperlyConfigured
|
|||
from rest_framework import exceptions, HTTP_HEADER_ENCODING
|
||||
from rest_framework.compat import CsrfViewMiddleware
|
||||
from rest_framework.compat import oauth, oauth_provider, oauth_provider_store
|
||||
from rest_framework.compat import oauth2_provider, oauth2_provider_forms
|
||||
from rest_framework.compat import oauth2_provider
|
||||
from rest_framework.authtoken.models import Token
|
||||
|
||||
|
||||
|
@ -325,11 +325,13 @@ class OAuth2Authentication(BaseAuthentication):
|
|||
except oauth2_provider.models.AccessToken.DoesNotExist:
|
||||
raise exceptions.AuthenticationFailed('Invalid token')
|
||||
|
||||
if not token.user.is_active:
|
||||
user = token.user
|
||||
|
||||
if not user.is_active:
|
||||
msg = 'User inactive or deleted: %s' % user.username
|
||||
raise exceptions.AuthenticationFailed(msg)
|
||||
|
||||
return (token.user, token)
|
||||
return (user, token)
|
||||
|
||||
def authenticate_header(self, request):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user