Skip to content

Commit

Permalink
✨Feat : 토큰 Refresh API 추가 #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Chestnut90 committed Nov 15, 2023
1 parent 96ac5a5 commit efdfc5f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,23 @@ def create(self, validated_data):

def update(self, instance, validated_data):
raise NotImplementedError()


class TokenRefreshRequestSerializer(serializers.Serializer):
refresh = serializers.CharField()

def create(self, validated_data):
raise NotImplementedError()

def update(self, instance, validated_data):
raise NotImplementedError()


class TokenRefreshResponseSerializer(serializers.Serializer):
access = serializers.CharField()

def create(self, validated_data):
raise NotImplementedError()

def update(self, instance, validated_data):
raise NotImplementedError()
3 changes: 2 additions & 1 deletion src/users/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.urls import path

from users.views import SignInAPIView, SignUpAPIView
from users.views import SignInAPIView, SignUpAPIView, TokenRefreshAPIView

urlpatterns = [
path("signup/", view=SignUpAPIView.as_view(), name="signup"),
path("signin/", view=SignInAPIView.as_view(), name="signin"),
path("token-refresh/", view=TokenRefreshAPIView.as_view(), name="token-refresh"),
]
17 changes: 16 additions & 1 deletion src/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework_simplejwt.views import TokenObtainPairView
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

from users.serializers import (
SignInRequestSerializer,
SignInResponseSerializer,
TokenRefreshRequestSerializer,
TokenRefreshResponseSerializer,
UserSignUpSerializer,
)

Expand Down Expand Up @@ -43,3 +45,16 @@ class SignInAPIView(TokenObtainPairView):
)
def post(self, request, *args, **kwargs):
return super().post(request, *args, **kwargs)


class TokenRefreshAPIView(TokenRefreshView):
@swagger_auto_schema(
operation_summary="사용자 토큰 리프레시",
request_body=TokenRefreshRequestSerializer,
responses={
status.HTTP_200_OK: TokenRefreshResponseSerializer,
# TODO : other response.
},
)
def post(self, request, *args, **kwargs):
return super().post(request, *args, **kwargs)

0 comments on commit efdfc5f

Please sign in to comment.