Remove: old logout view class
This commit is contained in:
parent
eb5e35df0a
commit
3eef803a94
2 changed files with 1 additions and 19 deletions
|
@ -1,8 +1,7 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import ProfileView, LogoutView
|
from .views import ProfileView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("logout/", LogoutView.as_view(), name="logout"),
|
|
||||||
path("profile/", ProfileView.as_view(), name="profile"),
|
path("profile/", ProfileView.as_view(), name="profile"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,24 +1,7 @@
|
||||||
from rest_framework.permissions import IsAuthenticated
|
from rest_framework.permissions import IsAuthenticated
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework.views import APIView
|
|
||||||
from rest_framework_simplejwt.tokens import RefreshToken
|
|
||||||
|
|
||||||
from .serializers import UserSerializer
|
from .serializers import UserSerializer
|
||||||
|
|
||||||
|
|
||||||
# Logout View
|
|
||||||
class LogoutView(APIView):
|
|
||||||
permission_classes = [IsAuthenticated]
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileView(APIView):
|
class ProfileView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
Loading…
Add table
Reference in a new issue