во время почтовой операции в почтальоне, получающем ошибку, Исключение: не авторизовано, почему мой пользователь не может войти в систему
class UserLoginViewSet(viewsets.ViewSet):
def create(self,request):
try:
data=request.data
email=data.get('email')
password=data.get('password')
date_of_birth=data.get('date_of_birth')
if not all([email,password]):
raise Exception('all fields are mandetory')
user=authenticate(email=email,password=password)
print('h',email)
print('b',password)
print(user)
if user is not None:
token=generate_token()
user_info=MyUser.objects.get(email=email)
data=({
'email':user_info.email,
'password':user_info.password,
#'data_of_birth':user_info.data_of_birth
})
return Response({"message": "You are successfully logged in",
"user_info":data,"token": token, "success": True},status=status.HTTP_200_OK)
else :
raise Exception('not authorised')
except Exception as error:
traceback.print_exc()
return Response({"message": str(error), "success": False}, status=status.HTTP_200_OK)