1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #9948: Fix TypeError exception when requesting API tokens list as non-authenticated user

This commit is contained in:
jeremystretch
2022-08-08 11:48:43 -04:00
parent 36ac83a319
commit 876251c1cf
2 changed files with 3 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ class TokenViewSet(NetBoxModelViewSet):
# Workaround for schema generation (drf_yasg)
if getattr(self, 'swagger_fake_view', False):
return queryset.none()
if not self.request.user.is_authenticated:
return queryset.none()
if self.request.user.is_superuser:
return queryset
return queryset.filter(user=self.request.user)