Skip to content

Commit 387182a

Browse files
committed
Refactor MyPermissionViewSet
1 parent 3f54e8e commit 387182a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

api/permissions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ def has_object_permission(self, request, view, obj):
222222

223223
class IdentificationTaskPermissions(BaseIdentificationTaskPermissions):
224224
def has_permission(self, request, view):
225+
if not request.user or not request.user.is_authenticated:
226+
return False
227+
225228
role_perm = False
226229
if view.action == 'list':
227230
role_perm = UserRolePermission().check_permissions(

api/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
DestroyModelMixin,
2626
)
2727
from rest_framework.parsers import MultiPartParser, FormParser
28-
from rest_framework.permissions import AllowAny, SAFE_METHODS
28+
from rest_framework.permissions import AllowAny, IsAuthenticated, SAFE_METHODS
2929
from rest_framework.response import Response
3030
from rest_framework.settings import api_settings
3131
from rest_framework.viewsets import ReadOnlyModelViewSet
@@ -425,8 +425,10 @@ def get_object(self):
425425
description="Get Current User's Permissions"
426426
)
427427
)
428-
class MyPermissionViewSet(MyUserViewSet):
428+
class MyPermissionViewSet(RetrieveModelMixin, GenericViewSet):
429+
queryset = None
429430
serializer_class = UserPermissionSerializer
431+
permission_classes = (IsAuthenticated,)
430432

431433
def get_object(self):
432434
user = self.request.user

0 commit comments

Comments
 (0)