clean up serializer file
This commit is contained in:
parent
13e072a2bc
commit
5516754de0
@ -28,11 +28,6 @@ class UserRegistrationView(GenericAPIView):
|
||||
data["tokens"] = {"refresh": str(token),
|
||||
"access": str(token.access_token)}
|
||||
return Response(data, status=status.HTTP_201_CREATED)
|
||||
# if serializer.is_valid():
|
||||
# user = serializer.save()
|
||||
# return Response({"id": user.id,
|
||||
# "username": user.username}, status=status.HTTP_201_CREATED)
|
||||
# return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
class UserLoginView(GenericAPIView):
|
||||
@ -49,36 +44,6 @@ class UserLoginView(GenericAPIView):
|
||||
data["tokens"] = {"refresh": str(token),
|
||||
"access": str(token.access_token)}
|
||||
return Response(data, status=status.HTTP_200_OK)
|
||||
# class UserLoginView(APIView):
|
||||
# authentication_classes = [JWTAuthentication]
|
||||
# permission_classes = [IsAuthenticated]
|
||||
|
||||
# def get(self, request):
|
||||
# content = {'message': 'Hello, World!'}
|
||||
# return Response(content)
|
||||
|
||||
|
||||
# class UserLoginView(APIView):
|
||||
# authentication_classes = [JWTAuthentication]
|
||||
# permission_classes = [IsAuthenticated]
|
||||
|
||||
# def post(self, request):
|
||||
# # Extract the token from the Authorization header
|
||||
# print(request)
|
||||
# auth_header = request.headers.get('Authorization')
|
||||
# if auth_header is None:
|
||||
# return Response({"error":
|
||||
# "Authorization header missing"},
|
||||
# status=status.HTTP_401_UNAUTHORIZED)
|
||||
# try:
|
||||
# # The token is expected to be in the format "Bearer <token>"
|
||||
# token_key = auth_header.split(' ')[1]
|
||||
# token = Token.objects.get(key=token_key)
|
||||
# user = token.user
|
||||
# return Response({"message": "Login successful", "user_id": user.id, "username": user.username}, status=status.HTTP_200_OK)
|
||||
# except (Token.DoesNotExist, IndexError):
|
||||
# return Response({"error": "Invalid token"}, status=status.HTTP_401_UNAUTHORIZED)
|
||||
|
||||
|
||||
|
||||
class UserLogoutView(GenericAPIView):
|
||||
@ -89,17 +54,7 @@ class UserLogoutView(GenericAPIView):
|
||||
refresh_token = request.data("refresh")
|
||||
token = RefreshToken(refresh_token)
|
||||
token.blacklist()
|
||||
return Response( status = status.HTTP_205_RESET_CONTENT)
|
||||
return Response(status=status.HTTP_205_RESET_CONTENT)
|
||||
except Exception as e:
|
||||
return Response( status = status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
# def post(self, request):
|
||||
# logout(request)
|
||||
# return Response({"message": "Logout successful"}, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print(e)
|
||||
return Response(status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user