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 7b08317
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ jobs:
run: docker compose build

- name: Migration test database
run: docker compose run django poetry run python src/manage.py migrate
run: docker compose run django python src/manage.py migrate

- name: Run isort
run: docker compose run django poetry run isort . --check
run: docker compose run django isort . --check

- name: Run black
run: docker compose run django poetry run black . --check
run: docker compose run django black . --check

- name: Run flake8
run: docker compose run django poetry run flake8
run: docker compose run django flake8

- name: Run Test
run: docker compose run django poetry run python3 src/manage.py test src
run: docker compose run django python src/manage.py test src
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 7b08317

Please sign in to comment.