shared_account app olib tashlandi
This commit is contained in:
0
core/apps/accounts/serializers/auth/__init__.py
Normal file
0
core/apps/accounts/serializers/auth/__init__.py
Normal file
18
core/apps/accounts/serializers/auth/login.py
Normal file
18
core/apps/accounts/serializers/auth/login.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# rest framework
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
# accounts
|
||||
from core.apps.accounts.models import User
|
||||
|
||||
|
||||
class LoginSerializer(serializers.Serializer):
|
||||
username = serializers.CharField()
|
||||
password = serializers.CharField()
|
||||
|
||||
def validate(self, data):
|
||||
user = User.objects.filter(username=data['username']).first()
|
||||
if not user or (user and not user.check_password(data['password'])):
|
||||
raise serializers.ValidationError({"user": "Username yoki parol noto'g'ri"})
|
||||
data['user'] = user
|
||||
return data
|
||||
1
core/apps/accounts/serializers/user/__init__.py
Normal file
1
core/apps/accounts/serializers/user/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .user import *
|
||||
22
core/apps/accounts/serializers/user/user.py
Normal file
22
core/apps/accounts/serializers/user/user.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# rest framework
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
# accounts
|
||||
from core.apps.accounts.models import User
|
||||
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = [
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'username',
|
||||
'phone_number',
|
||||
'profile_image',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user