Compare commits
No commits in common. "eb5e35df0a22f81fc4f43b107d05d5d6406d89cc" and "5a3c568a158fb0ea26231bea3fd54695611e5eef" have entirely different histories.
eb5e35df0a
...
5a3c568a15
6 changed files with 8 additions and 40 deletions
|
@ -1,6 +0,0 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "api.authentication"
|
|
@ -1,14 +0,0 @@
|
|||
from django.urls import path
|
||||
|
||||
from rest_framework_simplejwt.views import (
|
||||
TokenObtainPairView,
|
||||
TokenRefreshView,
|
||||
)
|
||||
|
||||
from api.authentication.views import LogoutView
|
||||
|
||||
urlpatterns = [
|
||||
path("logout/", LogoutView.as_view(), name="logout"),
|
||||
path("token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
|
||||
path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
|
||||
]
|
|
@ -1,18 +0,0 @@
|
|||
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)
|
|
@ -1,6 +1,12 @@
|
|||
from django.urls import path, include
|
||||
|
||||
from rest_framework_simplejwt.views import (
|
||||
TokenObtainPairView,
|
||||
TokenRefreshView,
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path("auth/", include("api.authentication.urls")),
|
||||
path("api/user/", include("api.user.urls")),
|
||||
path("api/token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
|
||||
path("api/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
|
||||
]
|
||||
|
|
|
@ -20,6 +20,6 @@ from django.urls import include, path
|
|||
|
||||
urlpatterns = [
|
||||
path("admin/", admin.site.urls),
|
||||
path("api/", include("api.urls")),
|
||||
path("", include("api.urls")),
|
||||
path("", include("images.urls")),
|
||||
]
|
||||
|
|
Loading…
Add table
Reference in a new issue