diff --git a/src/users/serializers.py b/src/users/serializers.py index ce5366b..91df49e 100644 --- a/src/users/serializers.py +++ b/src/users/serializers.py @@ -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() diff --git a/src/users/urls.py b/src/users/urls.py index 8283408..4e77fcd 100644 --- a/src/users/urls.py +++ b/src/users/urls.py @@ -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"), ] diff --git a/src/users/views.py b/src/users/views.py index af4da48..10e89ca 100644 --- a/src/users/views.py +++ b/src/users/views.py @@ -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, ) @@ -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)