diff --git a/aleksis/apps/kort/api.py b/aleksis/apps/kort/api.py index ceaad65f4f80c96e95ceba77576a03521528fb16..f9f9d119cd813588b4f65800527e7608c67ba251 100644 --- a/aleksis/apps/kort/api.py +++ b/aleksis/apps/kort/api.py @@ -8,7 +8,7 @@ from oauth2_provider.oauth2_backends import get_oauthlib_core from oauthlib.common import Request as OauthlibRequest from rest_framework import generics, serializers from rest_framework.authentication import BaseAuthentication -from rest_framework.exceptions import APIException, ValidationError +from rest_framework.exceptions import APIException, PermissionDenied, ValidationError from rest_framework.permissions import BasePermission from rest_framework.response import Response from rest_framework.views import APIView @@ -133,6 +133,8 @@ class CardPrinterDetails(generics.RetrieveAPIView): def get_object(self): token = self.request.auth + if not token: + raise PermissionDenied() return token.client.card_printers.all().first()