From 568d2b073112cdde69ce6c9f5ce5405cf60f2885 Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Wed, 31 Jul 2024 03:57:51 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20cd=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit github actions와 docker을 활용하여 cd --- .gitignore | 1 + accounts/models.py | 2 +- accounts/serializers.py | 2 +- accounts/views.py | 7 ++++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1f1b385..158121c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ env/ db.sqlite3 .DS_Store .env +.env.prod venv/ mguvenv/ diff --git a/accounts/models.py b/accounts/models.py index 669e810..f43bd8b 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -19,7 +19,7 @@ class User(AbstractUser): reliability = models.IntegerField(default=100) USERNAME_FIELD = "email" - REQUIRED_FIELDS = [] + REQUIRED_FIELDS = ["name"] def __str__(self): return self.name diff --git a/accounts/serializers.py b/accounts/serializers.py index fd344e4..cca8254 100644 --- a/accounts/serializers.py +++ b/accounts/serializers.py @@ -49,7 +49,7 @@ def create(self, validated_data): # 로그인 시리얼라이저 class LoginSerializer(serializers.Serializer): - username = serializers.EmailField(required=True) + email = serializers.EmailField(required=True) # write_only=True 를 통해 클라이언트->서버 만 가능하도록 설정 password = serializers.CharField(required=True, write_only=True) diff --git a/accounts/views.py b/accounts/views.py index 521b38d..47055b8 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -16,6 +16,7 @@ class LoginView(generics.GenericAPIView): def post(self, request): serializer = self.get_serializer(data=request.data) - serializer.is_valid(raise_exception=True) - token = serializer.validated_data - return Response({"token": token.key}, status=status.HTTP_200_OK) + if serializer.is_valid(): + token = serializer.validated_data + return Response({"token": token.key}, status=status.HTTP_200_OK) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)