def post(self, request): user = User.objects.create_guest_user() user.name = 'dummy user' user.save() serializer = TokenSerializer(data={'token': gen_jwt(user)}) serializer.is_valid(raise_exception=True) return Response(serializer.data)
def post(self, request): user = User.objects.create_guest_user() user.name = 'dummy user' user.save() payload = jwt_payload_handler(user) token = jwt_encode_handler(payload) serializer = TokenSerializer(data={'token': token}) serializer.is_valid(raise_exception=True) return Response(serializer.data)
def post(self, request): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = User.objects.create_user( email=serializer.validated_data["email"], password=serializer.validated_data["password"]) user.save() serializer = TokenSerializer(data={'token': gen_jwt(user)}) serializer.is_valid(raise_exception=True) return Response(serializer.data)
def post(self, request): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) if User.objects.filter(device_uuid=serializer.data['uuid']): message = {'detail': 'すでにそのユーザーは登録済みです。'} return Response(message, status=status.HTTP_400_BAD_REQUEST) user = User.objects.create_guest_user( device_uuid=serializer.data['uuid']) user.save() serializer = TokenSerializer(data={'token': gen_jwt(user)}) serializer.is_valid(raise_exception=True) return Response(serializer.data)
def post(self, request): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = User.objects.filter(device_uuid=serializer.data['uuid']).first() if user is None: message = {'detail': 'そのユーザーは存在しません'} return Response(message, status=status.HTTP_400_BAD_REQUEST) payload = jwt_payload_handler(user) token = jwt_encode_handler(payload) serializer = TokenSerializer(data={'token': token}) serializer.is_valid(raise_exception=True) return Response(serializer.data)