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,20 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from rest_framework import serializers
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
password = serializers.CharField(write_only=True)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ("id", "email", "full_name", "password")
|
||||
|
||||
def create(self, validated_data):
|
||||
user = User.objects.create_user(
|
||||
email=validated_data["email"],
|
||||
password=validated_data["password"],
|
||||
full_name=validated_data.get("full_name", ""),
|
||||
)
|
||||
return user
|
||||
Reference in New Issue
Block a user