Skip to content

Commit fb6ce5b

Browse files
committed
로그인 API 응답에 basic Auth 추가
1 parent dd2bd37 commit fb6ce5b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-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: 4 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

@@ -85,8 +86,10 @@ def login_api(request):
8586
login(request, user, backend="django.contrib.auth.backends.ModelBackend")
8687

8788
response_data = {
88-
"msg": "ok"
89+
"msg": "ok",
90+
"token": get_basic_auth_token(request.data["username"], request.data["password"])
8991
}
92+
9093
return Response(response_data)
9194

9295

0 commit comments

Comments
 (0)