*/api: fix lookups per user

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-04 21:58:20 +02:00
parent 08451c15f4
commit e674f03064
7 changed files with 8 additions and 8 deletions

View file

@ -50,4 +50,4 @@ class NotificationViewSet(
def get_queryset(self): def get_queryset(self):
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
return Notification.objects.filter(user=user) return Notification.objects.filter(user=user.pk)

View file

@ -42,7 +42,7 @@ class AuthorizationCodeViewSet(
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
if user.is_superuser: if user.is_superuser:
return super().get_queryset() return super().get_queryset()
return super().get_queryset().filter(user=user) return super().get_queryset().filter(user=user.pk)
class RefreshTokenViewSet( class RefreshTokenViewSet(
@ -62,4 +62,4 @@ class RefreshTokenViewSet(
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
if user.is_superuser: if user.is_superuser:
return super().get_queryset() return super().get_queryset()
return super().get_queryset().filter(user=user) return super().get_queryset().filter(user=user.pk)

View file

@ -30,4 +30,4 @@ class UserOAuthSourceConnectionViewSet(ModelViewSet):
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
if user.is_superuser: if user.is_superuser:
return super().get_queryset() return super().get_queryset()
return super().get_queryset().filter(user=user) return super().get_queryset().filter(user=user.pk)

View file

@ -46,7 +46,7 @@ class StaticDeviceViewSet(ModelViewSet):
def get_queryset(self): def get_queryset(self):
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
return StaticDevice.objects.filter(user=user) return StaticDevice.objects.filter(user=user.pk)
class StaticAdminDeviceViewSet(ReadOnlyModelViewSet): class StaticAdminDeviceViewSet(ReadOnlyModelViewSet):

View file

@ -49,7 +49,7 @@ class TOTPDeviceViewSet(ModelViewSet):
def get_queryset(self): def get_queryset(self):
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
return TOTPDevice.objects.filter(user=user) return TOTPDevice.objects.filter(user=user.pk)
class TOTPAdminDeviceViewSet(ReadOnlyModelViewSet): class TOTPAdminDeviceViewSet(ReadOnlyModelViewSet):

View file

@ -48,7 +48,7 @@ class WebAuthnDeviceViewSet(ModelViewSet):
def get_queryset(self): def get_queryset(self):
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
return WebAuthnDevice.objects.filter(user=user) return WebAuthnDevice.objects.filter(user=user.pk)
class WebAuthnAdminDeviceViewSet(ReadOnlyModelViewSet): class WebAuthnAdminDeviceViewSet(ReadOnlyModelViewSet):

View file

@ -54,4 +54,4 @@ class UserConsentViewSet(
user = self.request.user if self.request else get_anonymous_user() user = self.request.user if self.request else get_anonymous_user()
if user.is_superuser: if user.is_superuser:
return super().get_queryset() return super().get_queryset()
return super().get_queryset().filter(user=user) return super().get_queryset().filter(user=user.pk)