Skip to content

Commit 93ef0a4

Browse files
authored
Merge pull request #96 from golony6449/feature/golony/ticket
로그인 API 응답에 token 추가
2 parents 1f52783 + d86348c commit 93ef0a4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

account/logics.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import base64
2+
3+
4+
def get_basic_auth_token(username: str, password: str) -> str:
5+
userpass = username + ':' + password
6+
encoded_u = base64.b64encode(userpass.encode()).decode()
7+
8+
return encoded_u

account/views.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from rest_framework.views import APIView
1414
from rest_framework.decorators import api_view
1515

16+
from account.logics import get_basic_auth_token
1617
from account.view_models import UserTicketInfo
1718
from ticket.models import Ticket
1819

@@ -44,6 +45,9 @@ class MyPage(APIView):
4445
def get(self, request):
4546
dto = {
4647
"ticket": self.get_ticket_info(request)
48+
# "session": None, # TODO 세션
49+
# "sponsor": None, # TODO 후원사
50+
# "user_info": None # TODO 사용자 정보
4751
}
4852

4953
return Response(dto)
@@ -82,8 +86,10 @@ def login_api(request):
8286
login(request, user, backend="django.contrib.auth.backends.ModelBackend")
8387

8488
response_data = {
85-
"msg": "ok"
89+
"msg": "ok",
90+
"basic_auth_token": get_basic_auth_token(request.data["username"], request.data["password"])
8691
}
92+
8793
return Response(response_data)
8894

8995

0 commit comments

Comments
 (0)