fix(api): Use correct data field for rate limiting identity field

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2653>
This commit is contained in:
Georg Krause 2023-11-28 12:52:12 +00:00 committed by Marge
commit 150a9f68a4
5 changed files with 6 additions and 5 deletions

View file

@ -349,7 +349,7 @@ class ScopesSerializer(serializers.Serializer):
class IdentSerializer(serializers.Serializer):
type = serializers.CharField()
id = serializers.IntegerField()
id = serializers.CharField()
class RateLimitSerializer(serializers.Serializer):

View file

@ -7,7 +7,7 @@ from rest_framework import throttling as rest_throttling
def get_ident(user, request):
if user and user.is_authenticated:
return {"type": "authenticated", "id": user.pk}
return {"type": "authenticated", "id": f"{user.pk}"}
ident = rest_throttling.BaseThrottle().get_ident(request)
return {"type": "anonymous", "id": ident}