# add api logout
This commit is contained in:
parent
d6588fed1d
commit
eccc5e48c3
|
@ -1,9 +1,10 @@
|
|||
from django.urls import path
|
||||
from .views import UserLoginAPIView, UserDetailAPIView
|
||||
from .views import UserLoginAPIView, UserDetailAPIView, UserLogoutAPIView
|
||||
|
||||
|
||||
app_name = 'users-api'
|
||||
urlpatterns = [
|
||||
path('login/', UserLoginAPIView.as_view(), name='login'),
|
||||
path('logout/', UserLogoutAPIView.as_view(), name='logout'),
|
||||
path('info/', UserDetailAPIView.as_view(), name='info'),
|
||||
]
|
|
@ -38,6 +38,15 @@ class UserLoginAPIView(APIView):
|
|||
return Response(serializer.errors, HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
class UserLogoutAPIView(APIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
serializer_class = UserLoginSerializer
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
logout_data = {'msg': 'logout successfully'}
|
||||
return Response(logout_data, HTTP_200_OK)
|
||||
|
||||
|
||||
class UserDetailAPIView(RetrieveAPIView):
|
||||
serializer_class = UserDetailSerializer
|
||||
permission_classes = [AllowAny]
|
||||
|
|
Loading…
Reference in New Issue