Optimised login api

This commit is contained in:
Ruman Siddiqui
2023-08-10 18:43:03 +05:30
parent 9e612c7171
commit 4f02cef0f9
5 changed files with 79 additions and 26 deletions

View File

@ -215,10 +215,17 @@ class GuardianSerializer(serializers.ModelSerializer):
def get_user_type(self, obj):
"""user type"""
email_verified = UserEmailOtp.objects.filter(email=obj.user.username).last()
if email_verified and email_verified.user_type is not None:
return email_verified.user_type
return str(NUMBER['two'])
if self.context.get('user_type', ''):
return self.context.get('user_type')
# remove the below code once user_type can be passed
# from everywhere from where this serializer is being called
else:
email_verified = UserEmailOtp.objects.filter(
email=obj.user.username
).last()
if email_verified and email_verified.user_type is not None:
return email_verified.user_type
return str(NUMBER['two'])
def get_auth(self, obj):
"""user email address"""