aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Christie2012-09-05 13:04:07 +0100
committerTom Christie2012-09-05 13:04:07 +0100
commit367dd01a338e67c772362af62889a53a1302fb02 (patch)
treee1866b511152faa6bf4109ca02009d4fe3cae8e5
parentef5279e97c0aa083d44489cf374fa75c7c8f53b7 (diff)
downloaddjango-rest-framework-367dd01a338e67c772362af62889a53a1302fb02.tar.bz2
Fix permission issues
-rw-r--r--djangorestframework/permissions.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/djangorestframework/permissions.py b/djangorestframework/permissions.py
index d6405a36..eff2ed2b 100644
--- a/djangorestframework/permissions.py
+++ b/djangorestframework/permissions.py
@@ -41,7 +41,7 @@ class IsAuthenticated(BasePermission):
"""
def check_permission(self, request, obj=None):
- if request.user.is_authenticated():
+ if request.user and request.user.is_authenticated():
return True
return False
@@ -52,7 +52,7 @@ class IsAdminUser(BasePermission):
"""
def check_permission(self, request, obj=None):
- if request.user.is_staff:
+ if request.user and request.user.is_staff():
return True
return False
@@ -63,8 +63,9 @@ class IsAuthenticatedOrReadOnly(BasePermission):
"""
def check_permission(self, request, obj=None):
- if (request.user.is_authenticated() or
- request.method in SAFE_METHODS):
+ if (request.method in SAFE_METHODS or
+ request.user and
+ request.user.is_authenticated()):
return True
return False
@@ -108,6 +109,8 @@ class DjangoModelPermissions(BasePermission):
model_cls = self.view.model
perms = self.get_required_permissions(request.method, model_cls)
- if request.user.is_authenticated() and request.user.has_perms(perms, obj):
+ if (request.user and
+ request.user.is_authenticated() and
+ request.user.has_perms(perms, obj)):
return True
return False