Remove: old logout auth api view
This commit is contained in:
parent
dded1ecabc
commit
828c46b27c
3 changed files with 0 additions and 29 deletions
|
@ -1,5 +0,0 @@
|
||||||
from rest_framework import serializers
|
|
||||||
|
|
||||||
|
|
||||||
class LogoutSerializer(serializers.Serializer):
|
|
||||||
refresh = serializers.CharField()
|
|
|
@ -6,10 +6,7 @@ from rest_framework_simplejwt.views import (
|
||||||
TokenBlacklistView,
|
TokenBlacklistView,
|
||||||
)
|
)
|
||||||
|
|
||||||
from api.authentication.views import LogoutView
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("logout/", LogoutView.as_view(), name="logout"),
|
|
||||||
path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
|
path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
|
||||||
path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
|
path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
|
||||||
path("token/blacklist/", TokenBlacklistView.as_view(), name="token_blacklist"),
|
path("token/blacklist/", TokenBlacklistView.as_view(), name="token_blacklist"),
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework.views import APIView
|
|
||||||
from rest_framework.permissions import IsAuthenticated
|
|
||||||
from rest_framework_simplejwt.tokens import RefreshToken
|
|
||||||
|
|
||||||
from api.authentication.serializers import LogoutSerializer
|
|
||||||
|
|
||||||
|
|
||||||
# Logout View
|
|
||||||
class LogoutView(APIView):
|
|
||||||
permission_classes = [IsAuthenticated]
|
|
||||||
serializer_class = LogoutSerializer
|
|
||||||
|
|
||||||
def post(self, request):
|
|
||||||
try:
|
|
||||||
refresh_token = request.data["refresh"]
|
|
||||||
token = RefreshToken(refresh_token)
|
|
||||||
token.blacklist()
|
|
||||||
return Response({"message": "Logout successful"})
|
|
||||||
except Exception as e:
|
|
||||||
return Response({"error": str(e)}, status=400)
|
|
Loading…
Add table
Add a link
Reference in a new issue