Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 로그인 API 작성 #26

Merged
merged 9 commits into from
Jan 11, 2024
Prev Previous commit
Next Next commit
refactor(serializer): class 이름 변경
nyj001012 committed Jan 11, 2024
commit efc5628240d188fd493f29a41b735bfb408ef33e
37 changes: 9 additions & 28 deletions backend/login/serializers.py
Original file line number Diff line number Diff line change
@@ -2,33 +2,14 @@
from drf_yasg.utils import swagger_auto_schema


@swagger_auto_schema(
tags=["login"],
)
class GoogleLoginSerializer(serializers.Serializer):
def to_representation(self, instance):
return {
"access_token": instance["access_token"],
"refresh_token": instance["refresh_token"],
"user": {
"id": instance["user"].id,
"email": instance["user"].email,
"name": instance["user"].name,
},
}
class LoginRedirectSerializer(serializers.Serializer):
status = serializers.IntegerField(default=302)
redirect_uri = serializers.URLField(default='http://localhost:8000/login/authorization')


@swagger_auto_schema(
tags=["login"],
)
class Login42Serializer(serializers.Serializer):
def to_representation(self, instance):
return {
"access_token": instance["access_token"],
"refresh_token": instance["refresh_token"],
"user": {
"id": instance["user"].id,
"email": instance["user"].email,
"name": instance["user"].name,
},
}
class GoogleLoginSerializer(LoginRedirectSerializer):
pass


class FTLoginSerializer(LoginRedirectSerializer):
pass
16 changes: 3 additions & 13 deletions backend/src/urls.py
Original file line number Diff line number Diff line change
@@ -22,8 +22,6 @@
from drf_yasg import openapi


router = routers.DefaultRouter()

schema_view = get_schema_view(
openapi.Info(
title="ft_transcendence API",
@@ -36,17 +34,9 @@
)

urlpatterns = [
path('swagger<format>/', schema_view.without_ui(cache_timeout=0), name='schema-json'),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('admin/', admin.site.urls),
path('login/', include('login.urls')),
]

# DEBUG 모드일 경우, ui 없이 swagger view를 사용할 수 있도록 설정
if settings.DEBUG:
urlpatterns += [
re_path(r'^swagger(?P<format>\.json|\.yaml)$',
schema_view.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^swagger/$', schema_view.with_ui('swagger',
cache_timeout=0), name='schema-swagger-ui'),
re_path(r'^redoc/$', schema_view.with_ui('redoc',
cache_timeout=0), name='schema-redoc'),
]