mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
check authentication after checking ModelResource
This commit is contained in:
parent
bc80eb266f
commit
b236241982
|
@ -99,16 +99,16 @@ class DjangoModelPermisson(BasePermission):
|
|||
if self.view.request.method in ('GET', 'OPTIONS', 'HEAD',):
|
||||
return
|
||||
|
||||
# User must be logged in to check permissions.
|
||||
if not hasattr(self.view.request, 'user') or not self.view.request.user.is_authenticated():
|
||||
raise _403_FORBIDDEN_RESPONSE
|
||||
|
||||
klass = self.view.resource.model
|
||||
|
||||
# If it doesn't look like a model, we can't check permissions.
|
||||
if not klass or not getattr(klass, '_meta', None):
|
||||
return
|
||||
|
||||
# User must be logged in to check permissions.
|
||||
if not hasattr(self.view.request, 'user') or not self.view.request.user.is_authenticated():
|
||||
raise _403_FORBIDDEN_RESPONSE
|
||||
|
||||
permission_map = {
|
||||
'POST': ['%s.add_%s'],
|
||||
'PUT': ['%s.change_%s'],
|
||||
|
|
Loading…
Reference in New Issue
Block a user