-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
로그인 기능 추가 입력한 이메일, 비밀번호와 일치하는 유저가 존재하면 해당 유저의 토큰 반환
- Loading branch information
1 parent
f8d84b8
commit bf67c6c
Showing
4 changed files
with
24 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from django.urls import path | ||
from .views import RegisterView | ||
from .views import RegisterView, LoginView | ||
|
||
urlpatterns = [ | ||
path("register/", RegisterView.as_view()), | ||
path("login/", LoginView.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
# from django.shortcuts import render | ||
from .models import User | ||
from rest_framework import generics | ||
from rest_framework import generics, status | ||
from rest_framework.response import Response | ||
|
||
from .serializers import RegisterSerializer | ||
from .serializers import RegisterSerializer, LoginSerializer | ||
|
||
|
||
class RegisterView(generics.CreateAPIView): | ||
queryset = User.objects.all() | ||
serializer_class = RegisterSerializer | ||
|
||
|
||
class LoginView(generics.GenericAPIView): | ||
serializer_class = LoginSerializer | ||
|
||
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) |