Exemple #1
0
    def get(self, request):
        # 获取token
        token = request.query_params.get('token')
        print(token)
        try:
            uid = token_confirm.confirm_validate_token(token)
        except Exception as e:
            print(e)
            return Response({
                'code': 107,
                'msg': 'token失效,请重新登录',
                'data': {},
            })

        try:
            user = AxfUser.objects.get(pk=uid)
        except Exception as e:
            print(e)
            return Response({
                'code': 107,
                'msg': '用户不存在',
                'data': {},
            })

        # 存在用户,序列化
        serializer = UserSerializer(user)
        return Response({
            'code': 200,
            'msg': '用户查询成功',
            'data': {
                'user_info': serializer.data
            },
            'orders_not_pay_num': 0,  # 待付款
            'orders_not_send_num': 0  # 待收货
        })
 def authenticate(self, request):
     # 获取token值
     token = request.data.get('token', None) or request.query_params.get(
         'token', None)
     print(11, token)
     try:
         uid = token_confirm.confirm_validate_token(token)
     except Exception as e:
         return
     try:
         user = CartoonUser.objects.get(pk=uid)
     except Exception as e:
         return
     print(22)
     # 验证成功
     return user, token
Exemple #3
0
 def authenticate(self, request):
     # 获取token
     token = request.data.get('token', None) or request.query_params.get('token', None)
     try:
         uid = token_confirm.confirm_validate_token(token)
     except Exception as e:
         # print(e)
         # raise APIException({'code': 1006, 'msg': 'token失效', 'data': {}, })
         return
     # 判断用户是否存在
     try:
         user = AxfUser.objects.get(pk=uid)
     except Exception as e:
         # print(e)
         # raise APIException({'code': 1006, 'msg': '用户不存在', 'data': {}, })
         return
     # 验证成功
     return user, token
 def authenticate(self, request):
     # 获取token值
     token = request.data.get('token', None) or request.query_params.get(
         'token', None)
     print(11, token)
     try:
         uid = token_confirm.confirm_validate_token(token)
     except Exception as e:
         # print(e)
         return
     try:
         user = ManageUser.objects.get(pk=uid)
     except Exception as e:
         # print(e)
         # raise APIException({'code': 1006, 'msg': '用户不存在', 'data': {}})
         return
     print(22)
     # 验证成功
     return user, token
Exemple #5
0
    def get(self, request):
        #获取token
        token = request.query_params.get('token')
        try:
            uid = token_confirm.confirm_validate_token(token)
        except Exception as e:
            print(e)
            return Response({'code': 107, 'msg': 'token失效,请重新登录', 'data': {}})
        # 获取到了uid
        try:
            user = ManageUser.objects.get(pk=uid)
        except Exception as e:
            print(e)
            return Response({'code': 107, 'msg': '该用户不存在', 'data': {}})

        # 序列化
        serializer = ManagerSerializers(instance=user)
        return Response({
            'code': 200,
            'msg': '查询成功',
            'data': {
                'user_info': serializer.data
            }
        })