mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 21:39:49 +00:00
handle logout, #855
This commit is contained in:
@@ -5,5 +5,6 @@ from user import views
|
||||
|
||||
urlpatterns = [
|
||||
path("login/", views.LoginApiView.as_view(), name="api-user-login"),
|
||||
path("logout/", views.LogoutApiView.as_view(), name="api-user-logout"),
|
||||
path("me/", views.UserConfigView.as_view(), name="api-user-me"),
|
||||
]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""all user api views"""
|
||||
|
||||
from common.views import ApiBaseView
|
||||
from django.contrib.auth import authenticate, login
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from rest_framework.permissions import AllowAny
|
||||
@@ -82,3 +82,14 @@ class LoginApiView(APIView):
|
||||
return Response({"message": "Login successful"}, status=200)
|
||||
|
||||
return Response({"message": "Invalid credentials"}, status=400)
|
||||
|
||||
|
||||
class LogoutApiView(ApiBaseView):
|
||||
"""resolves to /api/user/logout/
|
||||
POST: handle logout
|
||||
"""
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""logout on post request"""
|
||||
logout(request)
|
||||
return Response({"message": "Successfully logged out."}, status=200)
|
||||
|
||||
Reference in New Issue
Block a user