Esempio n. 1
0
File: auth.py Progetto: sz-2013/sz
 def post(self, request):
     serializer = AuthRequestSerializer(data=request.DATA)
     if serializer.is_valid():
         user = serializer.object['user']
         if not user.is_active:
             return Response('Account is not active', HTTP_423_LOCKED)
         auth.login(request, user)
         response = token_in_data(request, user)
         return Response(response)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Esempio n. 2
0
 def post(self, request):
     serializer = AuthRequestSerializer(data=request.DATA)
     if serializer.is_valid():
         user = serializer.object['user']
         if not user.is_active:
             return Response('Account is not active', HTTP_423_LOCKED)
         auth.login(request, user)
         user_serializer = AuthUserSerializer(instance=user)
         csrf.get_token(request)
         return Response(user_serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Esempio n. 3
0
 def post(self, request):
     serializer = AuthRequestSerializer(data=request.DATA)
     if serializer.is_valid():
         user = serializer.object['user']
         if not user.is_active:
             return Response('Account is not active', HTTP_423_LOCKED)
         auth.login(request, user)
         user_serializer = AuthUserSerializer(instance=user)
         csrf.get_token(request)
         return Response(user_serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)