Exemplo n.º 1
0
 def passage(self, request):
     data = json.loads(request.body)
     filter_user = Users.objects.filter(username=data['user_id'])
     user = UserSerializer(filter_user, many=True).data[0]
     data['user_id'] = user.get('id')
     # print(data)
     Passage.objects.create(**data)
     res = {"success": True, "data": True}
     return Response(res)
Exemplo n.º 2
0
 def login(self, request):
     data = json.loads(request.body)
     filter_user = Users.objects.filter(username=data['username'])
     if not len(filter_user):
         res = {"success": True, "data": False}
         return Response(res)
     user = UserSerializer(filter_user, many=True).data[0]
     check_pass_result = check_password(data['password'], user['password'])
     if not check_pass_result:
         res = {"success": True, "data": False}
         return Response(res)
     # print(user.get('username'))
     # print(user.get('imgUrl'))
     res = {
         "success": True,
         "data": True,
         "username": user.get('name'),
         "imgUrl": user.get('imgUrl'),
         "userId": user.get('username')
     }
     return Response(res)