fix: review issues - add rate limiting for auth views, add __str__ to User model

This commit is contained in:
Marko (Hermes Implementer)
2026-05-26 06:07:58 +00:00
parent fc0531395d
commit e6e6c92c28
2 changed files with 15 additions and 1 deletions
+8 -1
View File
@@ -1,16 +1,22 @@
from typing import Any
from rest_framework import status
from rest_framework.decorators import api_view, permission_classes
from rest_framework.decorators import api_view, permission_classes, throttle_classes
from rest_framework.permissions import AllowAny
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.throttling import AnonRateThrottle
from accounts.serializers import LoginSerializer, RegisterSerializer, UserSerializer
class AuthRateThrottle(AnonRateThrottle):
scope = "auth"
@api_view(["POST"])
@permission_classes([AllowAny])
@throttle_classes([AuthRateThrottle])
def register_view(request: Request) -> Response:
"""Register a new user account."""
serializer = RegisterSerializer(data=request.data)
@@ -24,6 +30,7 @@ def register_view(request: Request) -> Response:
@api_view(["POST"])
@permission_classes([AllowAny])
@throttle_classes([AuthRateThrottle])
def login_view(request: Request) -> Response:
"""Authenticate a user and return JWT tokens."""
serializer = LoginSerializer(