File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 13
13
from rest_framework .views import APIView
14
14
from rest_framework .decorators import api_view
15
15
16
+ from account .logics import get_basic_auth_token
16
17
from account .view_models import UserTicketInfo
17
18
from ticket .models import Ticket
18
19
@@ -85,8 +86,10 @@ def login_api(request):
85
86
login (request , user , backend = "django.contrib.auth.backends.ModelBackend" )
86
87
87
88
response_data = {
88
- "msg" : "ok"
89
+ "msg" : "ok" ,
90
+ "token" : get_basic_auth_token (request .data ["username" ], request .data ["password" ])
89
91
}
92
+
90
93
return Response (response_data )
91
94
92
95
You can’t perform that action at this time.
0 commit comments