Move: auth to new api seperate app
This commit is contained in:
parent
5a3c568a15
commit
6ca01d7bdf
5 changed files with 39 additions and 7 deletions
18
backend/api/authentication/views.py
Normal file
18
backend/api/authentication/views.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
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
|
||||
|
||||
|
||||
# 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)
|
Loading…
Add table
Add a link
Reference in a new issue