ft_transcendence/srcs/accounts/views/logout.py
2023-11-23 16:43:30 +01:00

13 lines
522 B
Python

from rest_framework.views import APIView
from django.contrib.auth import logout
from rest_framework import permissions, status
from rest_framework.response import Response
from django.http import HttpRequest
from rest_framework.authentication import SessionAuthentication
class LogoutView(APIView):
permission_classes = (permissions.IsAuthenticated,)
authentication_classes = (SessionAuthentication,)
def post(self, request: HttpRequest):
logout(request)
return Response("user unlogged", status=status.HTTP_200_OK)