mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 08:56:52 +00:00
feat: implement custom user model with JWT authentication and registration endpoints
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from rest_framework import generics, permissions
|
||||
|
||||
from .serializers import UserSerializer
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class RegisterView(generics.CreateAPIView):
|
||||
queryset = User.objects.all()
|
||||
permission_classes = (permissions.AllowAny,)
|
||||
serializer_class = UserSerializer
|
||||
|
||||
|
||||
class MeView(generics.RetrieveAPIView):
|
||||
serializer_class = UserSerializer
|
||||
permission_classes = (permissions.IsAuthenticated,)
|
||||
|
||||
def get_object(self):
|
||||
# Returns the user associated with the JWT token in the request
|
||||
return self.request.user
|
||||
Reference in New Issue
Block a user