summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2021-11-09 22:23:26 +0100
committerjdlugosz963 <jdlugosz963@gmail.com>2021-11-09 22:23:26 +0100
commit45daed0c4fd60febf9458c889f7a89c0e5ab70bd (patch)
tree9c36e6b4568fab81ecf272be9b8abdbb22174c04
parent30da4738eee6c2436dd6f4d879069c0e3713eec6 (diff)
downloadlom_api-45daed0c4fd60febf9458c889f7a89c0e5ab70bd.tar.gz
lom_api-45daed0c4fd60febf9458c889f7a89c0e5ab70bd.zip
change login api
-rw-r--r--auth_api/views.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/auth_api/views.py b/auth_api/views.py
index caf4782..efd98b9 100644
--- a/auth_api/views.py
+++ b/auth_api/views.py
@@ -17,13 +17,21 @@ class LoginView(KnoxLoginView):
17 permission_classes = (permissions.AllowAny, ) 17 permission_classes = (permissions.AllowAny, )
18 18
19 def post(self, request, format=None): 19 def post(self, request, format=None):
20 serializer = AuthTokenSerializer(data=request.data) 20 token_serializer = AuthTokenSerializer(data=request.data)
21 serializer.is_valid(raise_exception=True) 21 token_serializer.is_valid(raise_exception=True)
22 user = serializer.validated_data['user'] 22 user = token_serializer.validated_data['user']
23
24 user_serializer = UserSerializer(user)
25
23 login(request, user) 26 login(request, user)
24 return super(LoginView, self).post(request, format=None) 27
28 response = super(LoginView, self).post(request, format=None)
29 response.data['user'] = user_serializer.data
30
31 return Response(response.data, status=200)
25 32
26class RegisterView(APIView): 33class RegisterView(APIView):
34 permission_classes = (permissions.AllowAny, )
27 35
28 def post(self, request): 36 def post(self, request):
29 serializer = RegisterUserSerializer(data=request.data) 37 serializer = RegisterUserSerializer(data=request.data)