diff options
-rw-r--r-- | auth_api/views.py | 16 |
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 | ||
26 | class RegisterView(APIView): | 33 | class 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) |