Esempio n. 1
0
 def put(self, request, *args, **kwargs):
     data = dict(request.data)
     url = data['url']
     reset = models.ResetPasswordUrl.objects.filter(url=url)
     if not reset:
         return Response({'error': tr._TR("This url already used for password reset!")})
     reset = reset[0]
     user = models.MainUser.objects.filter(pk=reset.user_pk)
     if not user:
         return Response({'error': tr._TR("Can't find this user!")})
     user = user[0]
     user.set_password(data['password1'])
     user.save()
     reset.delete()
     return Response({})
Esempio n. 2
0
 def put(self, request, *args, **kwargs):
     data = dict(request.data)
     url = data['url']
     reset = models.ResetPasswordUrl.objects.filter(url=url)
     if not reset:
         return Response(
             {'error': tr._TR("This url already used for password reset!")})
     reset = reset[0]
     user = models.MainUser.objects.filter(pk=reset.user_pk)
     if not user:
         return Response({'error': tr._TR("Can't find this user!")})
     user = user[0]
     user.set_password(data['password1'])
     user.save()
     reset.delete()
     return Response({})
Esempio n. 3
0
 def put(self, request, *args, **kwargs):
     """
         Login
     """
     data = dict(request.data)
     username = data.get("username", None)
     password = data.get('password', None)
     user = authenticate(username=username, password=password)
     if user is not None:
         login(request, user)
         return Response({'ok': user.pk})
     else:
         return Response({'error': tr._TR('Wrong username or password!')},
                         status=status.HTTP_400_BAD_REQUEST)
Esempio n. 4
0
 def put(self, request, *args, **kwargs):
     """
         Login
     """
     data = dict(request.data)
     username = data.get("username", None)
     password = data.get('password', None)
     user = authenticate(username=username, password=password)
     if user is not None:
         login(request, user)
         return Response({'ok': user.pk})
     else:
         return Response({'error': tr._TR('Wrong username or password!')},
                         status=status.HTTP_400_BAD_REQUEST)